Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_unittest.cc

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/pref_service_factory.h" 10 #include "base/prefs/pref_service_factory.h"
11 #include "base/prefs/testing_pref_store.h" 11 #include "base/prefs/testing_pref_store.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profiles_state.h" 13 #include "chrome/browser/profiles/profiles_state.h"
14 #include "chrome/browser/ui/app_list/app_list_service.h" 14 #include "chrome/browser/ui/app_list/app_list_service.h"
15 #include "chrome/browser/ui/app_list/app_list_service_impl.h" 15 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
16 #include "chrome/browser/ui/app_list/test/fake_profile.h" 16 #include "chrome/browser/ui/app_list/test/fake_profile.h"
17 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" 17 #include "chrome/browser/ui/app_list/test/fake_profile_store.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 class TestingAppListServiceImpl : public AppListServiceImpl { 23 class TestingAppListServiceImpl : public AppListServiceImpl {
24 public: 24 public:
25 TestingAppListServiceImpl(const CommandLine& command_line, 25 TestingAppListServiceImpl(const base::CommandLine& command_line,
26 PrefService* local_state, 26 PrefService* local_state,
27 scoped_ptr<ProfileStore> profile_store) 27 scoped_ptr<ProfileStore> profile_store)
28 : AppListServiceImpl(command_line, local_state, profile_store.Pass()), 28 : AppListServiceImpl(command_line, local_state, profile_store.Pass()),
29 showing_for_profile_(NULL), 29 showing_for_profile_(NULL),
30 destroy_app_list_call_count_(0) {} 30 destroy_app_list_call_count_(0) {}
31 31
32 Profile* showing_for_profile() const { 32 Profile* showing_for_profile() const {
33 return showing_for_profile_; 33 return showing_for_profile_;
34 } 34 }
35 35
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 int destroy_app_list_call_count_; 73 int destroy_app_list_call_count_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(TestingAppListServiceImpl); 75 DISALLOW_COPY_AND_ASSIGN(TestingAppListServiceImpl);
76 }; 76 };
77 77
78 class AppListServiceUnitTest : public testing::Test { 78 class AppListServiceUnitTest : public testing::Test {
79 public: 79 public:
80 AppListServiceUnitTest() {} 80 AppListServiceUnitTest() {}
81 81
82 void SetUp() override { 82 void SetUp() override {
83 SetupWithCommandLine(CommandLine(CommandLine::NO_PROGRAM)); 83 SetupWithCommandLine(base::CommandLine(base::CommandLine::NO_PROGRAM));
84 } 84 }
85 85
86 protected: 86 protected:
87 void SetupWithCommandLine(const CommandLine& command_line) { 87 void SetupWithCommandLine(const base::CommandLine& command_line) {
88 user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("udd")); 88 user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("udd"));
89 profile1_.reset( 89 profile1_.reset(
90 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1"))); 90 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1")));
91 profile2_.reset( 91 profile2_.reset(
92 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2"))); 92 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2")));
93 PrefRegistrySimple* pref_registry = new PrefRegistrySimple; 93 PrefRegistrySimple* pref_registry = new PrefRegistrySimple;
94 94
95 AppListService::RegisterPrefs(pref_registry); 95 AppListService::RegisterPrefs(pref_registry);
96 profiles::RegisterPrefs(pref_registry); 96 profiles::RegisterPrefs(pref_registry);
97 97
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 service_->Show(); 170 service_->Show();
171 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); 171 EXPECT_EQ(profile2_.get(), service_->showing_for_profile());
172 EXPECT_EQ(profile2_->GetPath(), 172 EXPECT_EQ(profile2_->GetPath(),
173 service_->GetProfilePath(profile_store_->GetUserDataDir())); 173 service_->GetProfilePath(profile_store_->GetUserDataDir()));
174 service_->SetProfilePath(profile1_->GetPath()); 174 service_->SetProfilePath(profile1_->GetPath());
175 EXPECT_EQ(profile1_->GetPath(), 175 EXPECT_EQ(profile1_->GetPath(),
176 service_->GetProfilePath(profile_store_->GetUserDataDir())); 176 service_->GetProfilePath(profile_store_->GetUserDataDir()));
177 } 177 }
178 178
179 TEST_F(AppListServiceUnitTest, EnableViaCommandLineFlag) { 179 TEST_F(AppListServiceUnitTest, EnableViaCommandLineFlag) {
180 CommandLine command_line(CommandLine::NO_PROGRAM); 180 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
181 command_line.AppendSwitch(switches::kEnableAppList); 181 command_line.AppendSwitch(switches::kEnableAppList);
182 SetupWithCommandLine(command_line); 182 SetupWithCommandLine(command_line);
183 service_->PerformStartupChecks(profile1_.get()); 183 service_->PerformStartupChecks(profile1_.get());
184 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); 184 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled));
185 } 185 }
186 186
187 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) { 187 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) {
188 CommandLine command_line(CommandLine::NO_PROGRAM); 188 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
189 command_line.AppendSwitch(switches::kResetAppListInstallState); 189 command_line.AppendSwitch(switches::kResetAppListInstallState);
190 SetupWithCommandLine(command_line); 190 SetupWithCommandLine(command_line);
191 service_->PerformStartupChecks(profile1_.get()); 191 service_->PerformStartupChecks(profile1_.get());
192 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); 192 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled));
193 } 193 }
194 194
195 TEST_F(AppListServiceUnitTest, UMAPrefStates) { 195 TEST_F(AppListServiceUnitTest, UMAPrefStates) {
196 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); 196 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled));
197 EXPECT_EQ(AppListService::ENABLE_NOT_RECORDED, 197 EXPECT_EQ(AppListService::ENABLE_NOT_RECORDED,
198 local_state_->GetInteger(prefs::kAppListEnableMethod)); 198 local_state_->GetInteger(prefs::kAppListEnableMethod));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, 234 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL,
235 local_state_->GetInteger(prefs::kAppListEnableMethod)); 235 local_state_->GetInteger(prefs::kAppListEnableMethod));
236 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); 236 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime));
237 237
238 // An auto-show here should update the enable method to prevent recording it 238 // An auto-show here should update the enable method to prevent recording it
239 // as ENABLE_FOR_APP_INSTALL. 239 // as ENABLE_FOR_APP_INSTALL.
240 service_->ShowForAppInstall(profile1_.get(), "", false); 240 service_->ShowForAppInstall(profile1_.get(), "", false);
241 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, 241 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED,
242 local_state_->GetInteger(prefs::kAppListEnableMethod)); 242 local_state_->GetInteger(prefs::kAppListEnableMethod));
243 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_mac.mm ('k') | chrome/browser/ui/app_list/search/search_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698