OLD | NEW |
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 Loading... |
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 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 launcher_controller_.get(), item_browser, 0, NULL, true)); | 2353 launcher_controller_.get(), item_browser, 0, NULL, true)); |
2350 EXPECT_TRUE(CheckMenuCreation( | 2354 EXPECT_TRUE(CheckMenuCreation( |
2351 launcher_controller_.get(), item_gmail, 0, NULL, false)); | 2355 launcher_controller_.get(), item_gmail, 0, NULL, false)); |
2352 } | 2356 } |
2353 | 2357 |
2354 // Check that V2 applications are creating items properly in the launcher when | 2358 // Check that V2 applications are creating items properly in the launcher when |
2355 // instantiated by the current user. | 2359 // instantiated by the current user. |
2356 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2360 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2357 V2AppHandlingTwoUsers) { | 2361 V2AppHandlingTwoUsers) { |
2358 InitLauncherController(); | 2362 InitLauncherController(); |
2359 // We need to create a dummy views delegate to be able to create a V2 app. | |
2360 scoped_ptr<TestViewsDelegateForAppTest> views_delegate( | |
2361 new TestViewsDelegateForAppTest()); | |
2362 // Create a profile for our second user (will be destroyed by the framework). | 2363 // Create a profile for our second user (will be destroyed by the framework). |
2363 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 2364 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
2364 // Check that there is a browser and a app launcher. | 2365 // Check that there is a browser and a app launcher. |
2365 EXPECT_EQ(2, model_->item_count()); | 2366 EXPECT_EQ(2, model_->item_count()); |
2366 | 2367 |
2367 // Add a v2 app. | 2368 // Add a v2 app. |
2368 V2App v2_app(profile(), extension1_); | 2369 V2App v2_app(profile(), extension1_); |
2369 EXPECT_EQ(3, model_->item_count()); | 2370 EXPECT_EQ(3, model_->item_count()); |
2370 | 2371 |
2371 // After switching users the item should go away. | 2372 // After switching users the item should go away. |
2372 SwitchActiveUser(profile2->GetProfileName()); | 2373 SwitchActiveUser(profile2->GetProfileName()); |
2373 EXPECT_EQ(2, model_->item_count()); | 2374 EXPECT_EQ(2, model_->item_count()); |
2374 | 2375 |
2375 // And it should come back when switching back. | 2376 // And it should come back when switching back. |
2376 SwitchActiveUser(profile()->GetProfileName()); | 2377 SwitchActiveUser(profile()->GetProfileName()); |
2377 EXPECT_EQ(3, model_->item_count()); | 2378 EXPECT_EQ(3, model_->item_count()); |
2378 } | 2379 } |
2379 | 2380 |
2380 // Check that V2 applications are creating items properly in edge cases: | 2381 // Check that V2 applications are creating items properly in edge cases: |
2381 // a background user creates a V2 app, gets active and inactive again and then | 2382 // a background user creates a V2 app, gets active and inactive again and then |
2382 // deletes the app. | 2383 // deletes the app. |
2383 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2384 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2384 V2AppHandlingTwoUsersEdgeCases) { | 2385 V2AppHandlingTwoUsersEdgeCases) { |
2385 InitLauncherController(); | 2386 InitLauncherController(); |
2386 // We need to create a dummy views delegate to be able to create a V2 app. | |
2387 scoped_ptr<TestViewsDelegateForAppTest> views_delegate( | |
2388 new TestViewsDelegateForAppTest()); | |
2389 // Create a profile for our second user (will be destroyed by the framework). | 2387 // Create a profile for our second user (will be destroyed by the framework). |
2390 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 2388 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
2391 // Check that there is a browser and a app launcher. | 2389 // Check that there is a browser and a app launcher. |
2392 EXPECT_EQ(2, model_->item_count()); | 2390 EXPECT_EQ(2, model_->item_count()); |
2393 | 2391 |
2394 // Switch to an inactive user. | 2392 // Switch to an inactive user. |
2395 SwitchActiveUser(profile2->GetProfileName()); | 2393 SwitchActiveUser(profile2->GetProfileName()); |
2396 EXPECT_EQ(2, model_->item_count()); | 2394 EXPECT_EQ(2, model_->item_count()); |
2397 | 2395 |
2398 // Add the v2 app to the inactive user and check that no item was added to | 2396 // 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 Loading... |
2740 | 2738 |
2741 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2739 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2742 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2740 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2743 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2741 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2744 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2742 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2745 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2743 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2746 | 2744 |
2747 launcher_controller_->UnpinAppWithID("1"); | 2745 launcher_controller_->UnpinAppWithID("1"); |
2748 ASSERT_EQ(initial_size, model_->items().size()); | 2746 ASSERT_EQ(initial_size, model_->items().size()); |
2749 } | 2747 } |
OLD | NEW |