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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2769323002: mash: Update shelf pin prefs in ShelfModelObserver overrides. (Closed)
Patch Set: Use ScopedPinSyncDisabler name suggestion. Created 3 years, 8 months 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 void AddAppListLauncherItem() { 530 void AddAppListLauncherItem() {
531 ash::ShelfItem app_list; 531 ash::ShelfItem app_list;
532 app_list.type = ash::TYPE_APP_LIST; 532 app_list.type = ash::TYPE_APP_LIST;
533 model_->Add(app_list); 533 model_->Add(app_list);
534 } 534 }
535 535
536 void InitLauncherController() { 536 void InitLauncherController() {
537 launcher_controller_.reset( 537 launcher_controller_.reset(
538 new ChromeLauncherControllerImpl(profile(), model_)); 538 new ChromeLauncherControllerImpl(profile(), model_));
539 // TODO(crbug.com/654622): Some tests break with a non-null static instance.
540 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
541 launcher_controller_->Init(); 539 launcher_controller_->Init();
542 } 540 }
543 541
544 void InitLauncherControllerWithBrowser() { 542 void InitLauncherControllerWithBrowser() {
545 InitLauncherController(); 543 InitLauncherController();
546 chrome::NewTab(browser()); 544 chrome::NewTab(browser());
547 browser()->window()->Show(); 545 browser()->window()->Show();
548 } 546 }
549 547
550 void RecreateChromeLauncher() { 548 void RecreateChromeLauncher() {
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 1986
1989 // Now launch request should not be ignored. 1987 // Now launch request should not be ignored.
1990 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 1988 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
1991 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 1989 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
1992 } 1990 }
1993 1991
1994 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { 1992 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) {
1995 SendListOfArcApps(); 1993 SendListOfArcApps();
1996 1994
1997 InitLauncherController(); 1995 InitLauncherController();
1996 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
1997 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
1998
1998 SetLauncherControllerHelper(new TestLauncherControllerHelper); 1999 SetLauncherControllerHelper(new TestLauncherControllerHelper);
1999 2000
2000 // App1 exists all the time. 2001 // App1 exists all the time.
2001 // App2 is created when primary user is active and destroyed when secondary 2002 // App2 is created when primary user is active and destroyed when secondary
2002 // user is active. 2003 // user is active.
2003 // App3 created when secondary user is active. 2004 // App3 created when secondary user is active.
2004 2005
2005 const std::string user2 = "user2"; 2006 const std::string user2 = "user2";
2006 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2007 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2007 const AccountId account_id( 2008 const AccountId account_id(
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", 2275 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2275 GetPinnedAppStatus()); 2276 GetPinnedAppStatus());
2276 } 2277 }
2277 2278
2278 // Check that with multi profile V1 apps are properly added / removed from the 2279 // Check that with multi profile V1 apps are properly added / removed from the
2279 // shelf. 2280 // shelf.
2280 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2281 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2281 V1AppUpdateOnUserSwitch) { 2282 V1AppUpdateOnUserSwitch) {
2282 // Create a browser item in the LauncherController. 2283 // Create a browser item in the LauncherController.
2283 InitLauncherController(); 2284 InitLauncherController();
2285 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2286 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2287
2284 EXPECT_EQ(2, model_->item_count()); 2288 EXPECT_EQ(2, model_->item_count());
2285 { 2289 {
2286 // Create a "windowed gmail app". 2290 // Create a "windowed gmail app".
2287 std::unique_ptr<V1App> v1_app( 2291 std::unique_ptr<V1App> v1_app(
2288 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); 2292 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url));
2289 EXPECT_EQ(3, model_->item_count()); 2293 EXPECT_EQ(3, model_->item_count());
2290 2294
2291 // After switching to a second user the item should be gone. 2295 // After switching to a second user the item should be gone.
2292 std::string user2 = "user2"; 2296 std::string user2 = "user2";
2293 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2297 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 10 matching lines...) Expand all
2304 // Note we destroy now the gmail app with the closure end. 2308 // Note we destroy now the gmail app with the closure end.
2305 } 2309 }
2306 EXPECT_EQ(2, model_->item_count()); 2310 EXPECT_EQ(2, model_->item_count());
2307 } 2311 }
2308 2312
2309 // Check edge cases with multi profile V1 apps in the shelf. 2313 // Check edge cases with multi profile V1 apps in the shelf.
2310 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2314 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2311 V1AppUpdateOnUserSwitchEdgecases) { 2315 V1AppUpdateOnUserSwitchEdgecases) {
2312 // Create a browser item in the LauncherController. 2316 // Create a browser item in the LauncherController.
2313 InitLauncherController(); 2317 InitLauncherController();
2318 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2319 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2314 2320
2315 // First test: Create an app when the user is not active. 2321 // First test: Create an app when the user is not active.
2316 std::string user2 = "user2"; 2322 std::string user2 = "user2";
2317 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2323 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2318 const AccountId account_id2( 2324 const AccountId account_id2(
2319 multi_user_util::GetAccountIdFromProfile(profile2)); 2325 multi_user_util::GetAccountIdFromProfile(profile2));
2320 const AccountId account_id( 2326 const AccountId account_id(
2321 multi_user_util::GetAccountIdFromProfile(profile())); 2327 multi_user_util::GetAccountIdFromProfile(profile()));
2322 { 2328 {
2323 // Create a "windowed gmail app". 2329 // Create a "windowed gmail app".
(...skipping 16 matching lines...) Expand all
2340 EXPECT_EQ(2, model_->item_count()); 2346 EXPECT_EQ(2, model_->item_count());
2341 SwitchActiveUser(account_id); 2347 SwitchActiveUser(account_id);
2342 EXPECT_EQ(2, model_->item_count()); 2348 EXPECT_EQ(2, model_->item_count());
2343 } 2349 }
2344 2350
2345 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). 2351 // Check edge case where a visiting V1 app gets closed (crbug.com/321374).
2346 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2352 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2347 V1CloseOnVisitingDesktop) { 2353 V1CloseOnVisitingDesktop) {
2348 // Create a browser item in the LauncherController. 2354 // Create a browser item in the LauncherController.
2349 InitLauncherController(); 2355 InitLauncherController();
2356 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2357 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2350 2358
2351 chrome::MultiUserWindowManager* manager = 2359 chrome::MultiUserWindowManager* manager =
2352 chrome::MultiUserWindowManager::GetInstance(); 2360 chrome::MultiUserWindowManager::GetInstance();
2353 2361
2354 // First create an app when the user is active. 2362 // First create an app when the user is active.
2355 std::string user2 = "user2"; 2363 std::string user2 = "user2";
2356 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2364 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2357 const AccountId account_id( 2365 const AccountId account_id(
2358 multi_user_util::GetAccountIdFromProfile(profile())); 2366 multi_user_util::GetAccountIdFromProfile(profile()));
2359 const AccountId account_id2( 2367 const AccountId account_id2(
(...skipping 24 matching lines...) Expand all
2384 } 2392 }
2385 SwitchActiveUser(account_id2); 2393 SwitchActiveUser(account_id2);
2386 EXPECT_EQ(2, model_->item_count()); 2394 EXPECT_EQ(2, model_->item_count());
2387 } 2395 }
2388 2396
2389 // Check edge cases with multi profile V1 apps in the shelf. 2397 // Check edge cases with multi profile V1 apps in the shelf.
2390 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2398 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2391 V1AppUpdateOnUserSwitchEdgecases2) { 2399 V1AppUpdateOnUserSwitchEdgecases2) {
2392 // Create a browser item in the LauncherController. 2400 // Create a browser item in the LauncherController.
2393 InitLauncherController(); 2401 InitLauncherController();
2402 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2403 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2404
2394 SetLauncherControllerHelper(new TestLauncherControllerHelper); 2405 SetLauncherControllerHelper(new TestLauncherControllerHelper);
2395 2406
2396 // First test: Create an app when the user is not active. 2407 // First test: Create an app when the user is not active.
2397 std::string user2 = "user2"; 2408 std::string user2 = "user2";
2398 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2409 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2399 const AccountId account_id( 2410 const AccountId account_id(
2400 multi_user_util::GetAccountIdFromProfile(profile())); 2411 multi_user_util::GetAccountIdFromProfile(profile()));
2401 const AccountId account_id2( 2412 const AccountId account_id2(
2402 multi_user_util::GetAccountIdFromProfile(profile2)); 2413 multi_user_util::GetAccountIdFromProfile(profile2));
2403 SwitchActiveUser(account_id2); 2414 SwitchActiveUser(account_id2);
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4431 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4421 shelf_controller->auto_hide()); 4432 shelf_controller->auto_hide());
4422 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4433 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4423 4434
4424 PrefService* prefs = profile()->GetTestingPrefService(); 4435 PrefService* prefs = profile()->GetTestingPrefService();
4425 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4436 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4426 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4437 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4427 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4438 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4428 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4439 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4429 } 4440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698