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

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

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix MRUWindowTracker and MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest Created 7 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 | Annotate | Revision Log
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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 return CreateMultiUserProfile("user1"); 935 return CreateMultiUserProfile("user1");
936 } 936 }
937 virtual void DestroyProfile(TestingProfile* profile) OVERRIDE { 937 virtual void DestroyProfile(TestingProfile* profile) OVERRIDE {
938 // Delete the profile through our profile manager. 938 // Delete the profile through our profile manager.
939 ProfileToNameMap::iterator it = created_profiles_.find(profile); 939 ProfileToNameMap::iterator it = created_profiles_.find(profile);
940 DCHECK(it != created_profiles_.end()); 940 DCHECK(it != created_profiles_.end());
941 profile_manager_->DeleteTestingProfile(it->second); 941 profile_manager_->DeleteTestingProfile(it->second);
942 created_profiles_.erase(it); 942 created_profiles_.erase(it);
943 } 943 }
944 944
945 virtual views::ViewsDelegate* CreateViewsDelegate() OVERRIDE {
946 return new TestViewsDelegateForAppTest;
947 }
948
945 private: 949 private:
946 typedef std::map<Profile*, std::string> ProfileToNameMap; 950 typedef std::map<Profile*, std::string> ProfileToNameMap;
947 TestingProfileManager* profile_manager() { return profile_manager_.get(); } 951 TestingProfileManager* profile_manager() { return profile_manager_.get(); }
948 952
949 chromeos::FakeUserManager* GetFakeUserManager() { 953 chromeos::FakeUserManager* GetFakeUserManager() {
950 return static_cast<chromeos::FakeUserManager*>( 954 return static_cast<chromeos::FakeUserManager*>(
951 chromeos::UserManager::Get()); 955 chromeos::UserManager::Get());
952 } 956 }
953 957
954 scoped_ptr<TestingProfileManager> profile_manager_; 958 scoped_ptr<TestingProfileManager> profile_manager_;
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 launcher_controller_.get(), item_browser, 0, NULL, true)); 2330 launcher_controller_.get(), item_browser, 0, NULL, true));
2327 EXPECT_TRUE(CheckMenuCreation( 2331 EXPECT_TRUE(CheckMenuCreation(
2328 launcher_controller_.get(), item_gmail, 0, NULL, false)); 2332 launcher_controller_.get(), item_gmail, 0, NULL, false));
2329 } 2333 }
2330 2334
2331 // Check that V2 applications are creating items properly in the launcher when 2335 // Check that V2 applications are creating items properly in the launcher when
2332 // instantiated by the current user. 2336 // instantiated by the current user.
2333 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2337 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2334 V2AppHandlingTwoUsers) { 2338 V2AppHandlingTwoUsers) {
2335 InitLauncherController(); 2339 InitLauncherController();
2336 // We need to create a dummy views delegate to be able to create a V2 app.
2337 scoped_ptr<TestViewsDelegateForAppTest> views_delegate(
2338 new TestViewsDelegateForAppTest());
2339 // Create a profile for our second user (will be destroyed by the framework). 2340 // Create a profile for our second user (will be destroyed by the framework).
2340 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 2341 TestingProfile* profile2 = CreateMultiUserProfile("user2");
2341 // Check that there is a browser and a app launcher. 2342 // Check that there is a browser and a app launcher.
2342 EXPECT_EQ(2, model_->item_count()); 2343 EXPECT_EQ(2, model_->item_count());
2343 2344
2344 // Add a v2 app. 2345 // Add a v2 app.
2345 V2App v2_app(profile(), extension1_); 2346 V2App v2_app(profile(), extension1_);
2346 EXPECT_EQ(3, model_->item_count()); 2347 EXPECT_EQ(3, model_->item_count());
2347 2348
2348 // After switching users the item should go away. 2349 // After switching users the item should go away.
2349 SwitchActiveUser(profile2->GetProfileName()); 2350 SwitchActiveUser(profile2->GetProfileName());
2350 EXPECT_EQ(2, model_->item_count()); 2351 EXPECT_EQ(2, model_->item_count());
2351 2352
2352 // And it should come back when switching back. 2353 // And it should come back when switching back.
2353 SwitchActiveUser(profile()->GetProfileName()); 2354 SwitchActiveUser(profile()->GetProfileName());
2354 EXPECT_EQ(3, model_->item_count()); 2355 EXPECT_EQ(3, model_->item_count());
2355 } 2356 }
2356 2357
2357 // Check that V2 applications are creating items properly in edge cases: 2358 // Check that V2 applications are creating items properly in edge cases:
2358 // a background user creates a V2 app, gets active and inactive again and then 2359 // a background user creates a V2 app, gets active and inactive again and then
2359 // deletes the app. 2360 // deletes the app.
2360 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2361 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2361 V2AppHandlingTwoUsersEdgeCases) { 2362 V2AppHandlingTwoUsersEdgeCases) {
2362 InitLauncherController(); 2363 InitLauncherController();
2363 // We need to create a dummy views delegate to be able to create a V2 app.
2364 scoped_ptr<TestViewsDelegateForAppTest> views_delegate(
2365 new TestViewsDelegateForAppTest());
2366 // Create a profile for our second user (will be destroyed by the framework). 2364 // Create a profile for our second user (will be destroyed by the framework).
2367 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 2365 TestingProfile* profile2 = CreateMultiUserProfile("user2");
2368 // Check that there is a browser and a app launcher. 2366 // Check that there is a browser and a app launcher.
2369 EXPECT_EQ(2, model_->item_count()); 2367 EXPECT_EQ(2, model_->item_count());
2370 2368
2371 // Switch to an inactive user. 2369 // Switch to an inactive user.
2372 SwitchActiveUser(profile2->GetProfileName()); 2370 SwitchActiveUser(profile2->GetProfileName());
2373 EXPECT_EQ(2, model_->item_count()); 2371 EXPECT_EQ(2, model_->item_count());
2374 2372
2375 // Add the v2 app to the inactive user and check that no item was added to 2373 // Add the v2 app to the inactive user and check that no item was added to
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 2715
2718 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2716 EXPECT_EQ(1, app_icon_loader->fetch_count());
2719 ASSERT_EQ(initial_size + 1, model_->items().size()); 2717 ASSERT_EQ(initial_size + 1, model_->items().size());
2720 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2718 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2721 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2719 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2722 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2720 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2723 2721
2724 launcher_controller_->UnpinAppWithID("1"); 2722 launcher_controller_->UnpinAppWithID("1");
2725 ASSERT_EQ(initial_size, model_->items().size()); 2723 ASSERT_EQ(initial_size, model_->items().size());
2726 } 2724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698