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 30 matching lines...) Expand all Loading... |
41 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
42 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
43 #include "extensions/common/extension.h" | 43 #include "extensions/common/extension.h" |
44 #include "extensions/common/manifest_constants.h" | 44 #include "extensions/common/manifest_constants.h" |
45 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
46 #include "ui/aura/client/window_tree_client.h" | 46 #include "ui/aura/client/window_tree_client.h" |
47 #include "ui/base/models/menu_model.h" | 47 #include "ui/base/models/menu_model.h" |
48 | 48 |
49 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
50 #include "apps/app_window_contents.h" | 50 #include "apps/app_window_contents.h" |
51 #include "apps/app_window_registry.h" | |
52 #include "ash/test/test_session_state_delegate.h" | 51 #include "ash/test/test_session_state_delegate.h" |
53 #include "ash/test/test_shell_delegate.h" | 52 #include "ash/test/test_shell_delegate.h" |
54 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 53 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
55 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 54 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
56 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 55 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
57 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 56 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
58 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 57 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
59 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 58 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
60 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 59 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
61 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 60 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
62 #include "chrome/common/chrome_constants.h" | 61 #include "chrome/common/chrome_constants.h" |
63 #include "chrome/common/chrome_switches.h" | 62 #include "chrome/common/chrome_switches.h" |
64 #include "chrome/test/base/testing_browser_process.h" | 63 #include "chrome/test/base/testing_browser_process.h" |
65 #include "chrome/test/base/testing_profile_manager.h" | 64 #include "chrome/test/base/testing_profile_manager.h" |
66 #include "content/public/browser/web_contents_observer.h" | 65 #include "content/public/browser/web_contents_observer.h" |
67 #include "content/public/test/test_utils.h" | 66 #include "content/public/test/test_utils.h" |
| 67 #include "extensions/browser/app_window/app_window_registry.h" |
68 #include "extensions/browser/app_window/native_app_window.h" | 68 #include "extensions/browser/app_window/native_app_window.h" |
69 #include "ui/aura/window.h" | 69 #include "ui/aura/window.h" |
70 #endif | 70 #endif |
71 | 71 |
72 using base::ASCIIToUTF16; | 72 using base::ASCIIToUTF16; |
73 using extensions::Extension; | 73 using extensions::Extension; |
74 using extensions::Manifest; | 74 using extensions::Manifest; |
75 using extensions::UnloadedExtensionInfo; | 75 using extensions::UnloadedExtensionInfo; |
76 | 76 |
77 namespace { | 77 namespace { |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 scoped_ptr<aura::Window> native_window_; | 735 scoped_ptr<aura::Window> native_window_; |
736 | 736 |
737 DISALLOW_COPY_AND_ASSIGN(V1App); | 737 DISALLOW_COPY_AND_ASSIGN(V1App); |
738 }; | 738 }; |
739 | 739 |
740 // A V2 application which gets created with an |extension| and for a |profile|. | 740 // A V2 application which gets created with an |extension| and for a |profile|. |
741 // Upon destruction it will properly close the application. | 741 // Upon destruction it will properly close the application. |
742 class V2App { | 742 class V2App { |
743 public: | 743 public: |
744 V2App(Profile* profile, const extensions::Extension* extension) { | 744 V2App(Profile* profile, const extensions::Extension* extension) { |
745 window_ = new apps::AppWindow(profile, new ChromeAppDelegate(), extension); | 745 window_ = new extensions::AppWindow(profile, new ChromeAppDelegate(), |
746 apps::AppWindow::CreateParams params = apps::AppWindow::CreateParams(); | 746 extension); |
747 window_->Init( | 747 extensions::AppWindow::CreateParams params = |
748 GURL(std::string()), new apps::AppWindowContentsImpl(window_), params); | 748 extensions::AppWindow::CreateParams(); |
| 749 window_->Init(GURL(std::string()), |
| 750 new apps::AppWindowContentsImpl(window_), params); |
749 } | 751 } |
750 | 752 |
751 virtual ~V2App() { | 753 virtual ~V2App() { |
752 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); | 754 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); |
753 window_->GetBaseWindow()->Close(); | 755 window_->GetBaseWindow()->Close(); |
754 destroyed_watcher.Wait(); | 756 destroyed_watcher.Wait(); |
755 } | 757 } |
756 | 758 |
757 apps::AppWindow* window() { return window_; } | 759 extensions::AppWindow* window() { return window_; } |
758 | 760 |
759 private: | 761 private: |
760 // The app window which represents the application. Note that the window | 762 // The app window which represents the application. Note that the window |
761 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets | 763 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets |
762 // called. | 764 // called. |
763 apps::AppWindow* window_; | 765 extensions::AppWindow* window_; |
764 | 766 |
765 DISALLOW_COPY_AND_ASSIGN(V2App); | 767 DISALLOW_COPY_AND_ASSIGN(V2App); |
766 }; | 768 }; |
767 | 769 |
768 // The testing framework to test multi profile scenarios. | 770 // The testing framework to test multi profile scenarios. |
769 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest | 771 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest |
770 : public ChromeLauncherControllerTest { | 772 : public ChromeLauncherControllerTest { |
771 protected: | 773 protected: |
772 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { | 774 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { |
773 } | 775 } |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 SwitchActiveUser(profile()->GetProfileName()); | 2308 SwitchActiveUser(profile()->GetProfileName()); |
2307 EXPECT_EQ(2, model_->item_count()); | 2309 EXPECT_EQ(2, model_->item_count()); |
2308 | 2310 |
2309 V2App v2_app_1(profile(), extension1_); | 2311 V2App v2_app_1(profile(), extension1_); |
2310 EXPECT_EQ(3, model_->item_count()); | 2312 EXPECT_EQ(3, model_->item_count()); |
2311 { | 2313 { |
2312 // Hide and show the app. | 2314 // Hide and show the app. |
2313 v2_app_1.window()->Hide(); | 2315 v2_app_1.window()->Hide(); |
2314 EXPECT_EQ(2, model_->item_count()); | 2316 EXPECT_EQ(2, model_->item_count()); |
2315 | 2317 |
2316 v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE); | 2318 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2317 EXPECT_EQ(3, model_->item_count()); | 2319 EXPECT_EQ(3, model_->item_count()); |
2318 } | 2320 } |
2319 { | 2321 { |
2320 // Switch user, hide and show the app and switch back. | 2322 // Switch user, hide and show the app and switch back. |
2321 SwitchActiveUser(profile2->GetProfileName()); | 2323 SwitchActiveUser(profile2->GetProfileName()); |
2322 EXPECT_EQ(2, model_->item_count()); | 2324 EXPECT_EQ(2, model_->item_count()); |
2323 | 2325 |
2324 v2_app_1.window()->Hide(); | 2326 v2_app_1.window()->Hide(); |
2325 EXPECT_EQ(2, model_->item_count()); | 2327 EXPECT_EQ(2, model_->item_count()); |
2326 | 2328 |
2327 v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE); | 2329 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2328 EXPECT_EQ(2, model_->item_count()); | 2330 EXPECT_EQ(2, model_->item_count()); |
2329 | 2331 |
2330 SwitchActiveUser(profile()->GetProfileName()); | 2332 SwitchActiveUser(profile()->GetProfileName()); |
2331 EXPECT_EQ(3, model_->item_count()); | 2333 EXPECT_EQ(3, model_->item_count()); |
2332 } | 2334 } |
2333 { | 2335 { |
2334 // Switch user, hide the app, switch back and then show it again. | 2336 // Switch user, hide the app, switch back and then show it again. |
2335 SwitchActiveUser(profile2->GetProfileName()); | 2337 SwitchActiveUser(profile2->GetProfileName()); |
2336 EXPECT_EQ(2, model_->item_count()); | 2338 EXPECT_EQ(2, model_->item_count()); |
2337 | 2339 |
2338 v2_app_1.window()->Hide(); | 2340 v2_app_1.window()->Hide(); |
2339 EXPECT_EQ(2, model_->item_count()); | 2341 EXPECT_EQ(2, model_->item_count()); |
2340 | 2342 |
2341 SwitchActiveUser(profile()->GetProfileName()); | 2343 SwitchActiveUser(profile()->GetProfileName()); |
2342 EXPECT_EQ(2, model_->item_count()); | 2344 EXPECT_EQ(2, model_->item_count()); |
2343 | 2345 |
2344 v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE); | 2346 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2345 EXPECT_EQ(3, model_->item_count()); | 2347 EXPECT_EQ(3, model_->item_count()); |
2346 } | 2348 } |
2347 { | 2349 { |
2348 // Create a second app, hide and show it and then hide both apps. | 2350 // Create a second app, hide and show it and then hide both apps. |
2349 V2App v2_app_2(profile(), extension1_); | 2351 V2App v2_app_2(profile(), extension1_); |
2350 EXPECT_EQ(3, model_->item_count()); | 2352 EXPECT_EQ(3, model_->item_count()); |
2351 | 2353 |
2352 v2_app_2.window()->Hide(); | 2354 v2_app_2.window()->Hide(); |
2353 EXPECT_EQ(3, model_->item_count()); | 2355 EXPECT_EQ(3, model_->item_count()); |
2354 | 2356 |
2355 v2_app_2.window()->Show(apps::AppWindow::SHOW_ACTIVE); | 2357 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2356 EXPECT_EQ(3, model_->item_count()); | 2358 EXPECT_EQ(3, model_->item_count()); |
2357 | 2359 |
2358 v2_app_1.window()->Hide(); | 2360 v2_app_1.window()->Hide(); |
2359 v2_app_2.window()->Hide(); | 2361 v2_app_2.window()->Hide(); |
2360 EXPECT_EQ(2, model_->item_count()); | 2362 EXPECT_EQ(2, model_->item_count()); |
2361 } | 2363 } |
2362 } | 2364 } |
2363 #endif // defined(OS_CHROMEOS) | 2365 #endif // defined(OS_CHROMEOS) |
2364 | 2366 |
2365 // Checks that the generated menu list properly activates items. | 2367 // Checks that the generated menu list properly activates items. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2681 | 2683 |
2682 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2684 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2683 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2685 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2684 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2686 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2685 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2687 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2686 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2688 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2687 | 2689 |
2688 launcher_controller_->UnpinAppWithID("1"); | 2690 launcher_controller_->UnpinAppWithID("1"); |
2689 ASSERT_EQ(initial_size, model_->items().size()); | 2691 ASSERT_EQ(initial_size, model_->items().size()); |
2690 } | 2692 } |
OLD | NEW |