1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/app_list/app_list_item_model.h"
6 #include "base/file_util.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/ui/views/aura/app_list/app_list_model_builder.h"
9 #include "chrome/browser/extensions/extension_service_unittest.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 class AppListModelBuilderTest
: public ExtensionServiceTestBase
{
15 AppListModelBuilderTest() {}
16 virtual ~AppListModelBuilderTest() {}
19 TEST_F(AppListModelBuilderTest
, Build
) {
20 // Load "app_list" extensions test profile. The test profile has 4 extensions:
21 // 1 dummy extension, 2 packaged extension apps and 1 hosted extension app.
22 FilePath source_install_dir
= data_dir_
23 .AppendASCII("app_list")
24 .AppendASCII("Extensions");
25 FilePath pref_path
= source_install_dir
27 .AppendASCII("Preferences");
28 InitializeInstalledExtensionService(pref_path
, source_install_dir
);
31 // There should be 4 extensions in the test profile.
32 const ExtensionSet
* extensions
= service_
->extensions();
33 ASSERT_EQ(static_cast<size_t>(4), extensions
->size());
35 scoped_ptr
<ash::AppListModel
> model(new ash::AppListModel());
36 AppListModelBuilder
builder(profile_
.get(), model
.get());
37 builder
.Build(std::string());
39 // Since we are in unit_tests and there is no browser, the model would have
40 // only 3 extension apps in the profile.
41 EXPECT_EQ(3, model
->item_count());
42 EXPECT_EQ("Hosted App", model
->GetItem(0)->title());
43 EXPECT_EQ("Packaged App 1", model
->GetItem(1)->title());
44 EXPECT_EQ("Packaged App 2", model
->GetItem(2)->title());