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 <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 65 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
66 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 66 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
67 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 67 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
68 #include "chrome/common/chrome_constants.h" | 68 #include "chrome/common/chrome_constants.h" |
69 #include "chrome/common/chrome_switches.h" | 69 #include "chrome/common/chrome_switches.h" |
70 #include "chrome/test/base/testing_browser_process.h" | 70 #include "chrome/test/base/testing_browser_process.h" |
71 #include "chrome/test/base/testing_profile_manager.h" | 71 #include "chrome/test/base/testing_profile_manager.h" |
72 #include "components/user_manager/fake_user_manager.h" | 72 #include "components/user_manager/fake_user_manager.h" |
73 #include "content/public/browser/web_contents_observer.h" | 73 #include "content/public/browser/web_contents_observer.h" |
74 #include "content/public/test/test_utils.h" | 74 #include "content/public/test/test_utils.h" |
| 75 #include "content/public/test/web_contents_tester.h" |
75 #include "extensions/browser/app_window/app_window_contents.h" | 76 #include "extensions/browser/app_window/app_window_contents.h" |
76 #include "extensions/browser/app_window/app_window_registry.h" | 77 #include "extensions/browser/app_window/app_window_registry.h" |
77 #include "extensions/browser/app_window/native_app_window.h" | 78 #include "extensions/browser/app_window/native_app_window.h" |
78 #include "ui/aura/window.h" | 79 #include "ui/aura/window.h" |
79 #endif | 80 #endif |
80 | 81 |
81 #if defined(USE_AURA) | 82 #if defined(USE_AURA) |
82 #include "chrome/test/base/test_browser_window_aura.h" | 83 #include "chrome/test/base/test_browser_window_aura.h" |
83 #endif // defined(USE_AURA) | 84 #endif // defined(USE_AURA) |
84 | 85 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 // The native window we use. | 739 // The native window we use. |
739 scoped_ptr<aura::Window> native_window_; | 740 scoped_ptr<aura::Window> native_window_; |
740 | 741 |
741 DISALLOW_COPY_AND_ASSIGN(V1App); | 742 DISALLOW_COPY_AND_ASSIGN(V1App); |
742 }; | 743 }; |
743 | 744 |
744 // A V2 application which gets created with an |extension| and for a |profile|. | 745 // A V2 application which gets created with an |extension| and for a |profile|. |
745 // Upon destruction it will properly close the application. | 746 // Upon destruction it will properly close the application. |
746 class V2App { | 747 class V2App { |
747 public: | 748 public: |
748 V2App(Profile* profile, const extensions::Extension* extension) { | 749 V2App(Profile* profile, const extensions::Extension* extension) |
| 750 : creator_web_contents_( |
| 751 content::WebContentsTester::CreateTestWebContents(profile, |
| 752 nullptr)) { |
749 window_ = new extensions::AppWindow(profile, new ChromeAppDelegate(true), | 753 window_ = new extensions::AppWindow(profile, new ChromeAppDelegate(true), |
750 extension); | 754 extension); |
751 extensions::AppWindow::CreateParams params = | 755 extensions::AppWindow::CreateParams params = |
752 extensions::AppWindow::CreateParams(); | 756 extensions::AppWindow::CreateParams(); |
| 757 // Note: normally, the creator RFH is the background page of the |
| 758 // app/extension |
| 759 // calling chrome.app.window.create. For unit testing purposes, just passing |
| 760 // in a random RenderFrameHost is Good Enoughâ„¢. |
753 window_->Init(GURL(std::string()), | 761 window_->Init(GURL(std::string()), |
754 new extensions::AppWindowContentsImpl(window_), params); | 762 new extensions::AppWindowContentsImpl(window_), |
| 763 creator_web_contents_->GetMainFrame(), params); |
755 } | 764 } |
756 | 765 |
757 virtual ~V2App() { | 766 virtual ~V2App() { |
758 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); | 767 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); |
759 window_->GetBaseWindow()->Close(); | 768 window_->GetBaseWindow()->Close(); |
760 destroyed_watcher.Wait(); | 769 destroyed_watcher.Wait(); |
761 } | 770 } |
762 | 771 |
763 extensions::AppWindow* window() { return window_; } | 772 extensions::AppWindow* window() { return window_; } |
764 | 773 |
765 private: | 774 private: |
| 775 scoped_ptr<content::WebContents> creator_web_contents_; |
| 776 |
766 // The app window which represents the application. Note that the window | 777 // The app window which represents the application. Note that the window |
767 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets | 778 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets |
768 // called. | 779 // called. |
769 extensions::AppWindow* window_; | 780 extensions::AppWindow* window_; |
770 | 781 |
771 DISALLOW_COPY_AND_ASSIGN(V2App); | 782 DISALLOW_COPY_AND_ASSIGN(V2App); |
772 }; | 783 }; |
773 | 784 |
774 // The testing framework to test multi profile scenarios. | 785 // The testing framework to test multi profile scenarios. |
775 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest | 786 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest |
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2860 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
2850 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2861 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
2851 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2862 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
2852 | 2863 |
2853 launcher_controller_->CloseLauncherItem(shelfId3); | 2864 launcher_controller_->CloseLauncherItem(shelfId3); |
2854 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 2865 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
2855 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2866 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
2856 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2867 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
2857 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2868 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
2858 } | 2869 } |
OLD | NEW |