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 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void SetUpAppWithWindows(int num_windows) { | 24 void SetUpAppWithWindows(int num_windows) { |
25 app_ = InstallExtension( | 25 app_ = InstallExtension( |
26 test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"), 1); | 26 test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"), 1); |
27 EXPECT_TRUE(app_); | 27 EXPECT_TRUE(app_); |
28 | 28 |
29 for (int i = 0; i < num_windows; ++i) { | 29 for (int i = 0; i < num_windows; ++i) { |
30 content::WindowedNotificationObserver app_loaded_observer( | 30 content::WindowedNotificationObserver app_loaded_observer( |
31 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 31 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
32 content::NotificationService::AllSources()); | 32 content::NotificationService::AllSources()); |
33 OpenApplication(AppLaunchParams( | 33 OpenApplication( |
34 profile(), app_, extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW)); | 34 AppLaunchParams(Profile::FromBrowserContext(browser_context()), |
| 35 app_, |
| 36 extensions::LAUNCH_CONTAINER_NONE, |
| 37 NEW_WINDOW)); |
35 app_loaded_observer.Wait(); | 38 app_loaded_observer.Wait(); |
36 } | 39 } |
37 } | 40 } |
38 | 41 |
39 const extensions::Extension* app_; | 42 const extensions::Extension* app_; |
40 | 43 |
41 private: | 44 private: |
42 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoaBrowserTest); | 45 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoaBrowserTest); |
43 }; | 46 }; |
44 | 47 |
45 } // namespace | 48 } // namespace |
46 | 49 |
47 // Test interaction of Hide/Show() with Hide/ShowWithApp(). | 50 // Test interaction of Hide/Show() with Hide/ShowWithApp(). |
48 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, HideShowWithApp) { | 51 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, HideShowWithApp) { |
49 SetUpAppWithWindows(2); | 52 SetUpAppWithWindows(2); |
50 apps::ShellWindowRegistry::ShellWindowList windows = | 53 apps::ShellWindowRegistry::ShellWindowList windows = |
51 apps::ShellWindowRegistry::Get(profile())->shell_windows(); | 54 apps::ShellWindowRegistry::Get(browser_context())->shell_windows(); |
52 apps::NativeAppWindow* window = windows.front()->GetBaseWindow(); | 55 apps::NativeAppWindow* window = windows.front()->GetBaseWindow(); |
53 NSWindow* ns_window = window->GetNativeWindow(); | 56 NSWindow* ns_window = window->GetNativeWindow(); |
54 apps::NativeAppWindow* other_window = windows.back()->GetBaseWindow(); | 57 apps::NativeAppWindow* other_window = windows.back()->GetBaseWindow(); |
55 NSWindow* other_ns_window = other_window->GetNativeWindow(); | 58 NSWindow* other_ns_window = other_window->GetNativeWindow(); |
56 | 59 |
57 // Normal Hide/Show. | 60 // Normal Hide/Show. |
58 window->Hide(); | 61 window->Hide(); |
59 EXPECT_FALSE([ns_window isVisible]); | 62 EXPECT_FALSE([ns_window isVisible]); |
60 window->Show(); | 63 window->Show(); |
61 EXPECT_TRUE([ns_window isVisible]); | 64 EXPECT_TRUE([ns_window isVisible]); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 other_window->Hide(); | 100 other_window->Hide(); |
98 EXPECT_FALSE([other_ns_window isVisible]); | 101 EXPECT_FALSE([other_ns_window isVisible]); |
99 | 102 |
100 // HideWithApp, ShowWithApp does not show the other window. | 103 // HideWithApp, ShowWithApp does not show the other window. |
101 window->HideWithApp(); | 104 window->HideWithApp(); |
102 EXPECT_FALSE([ns_window isVisible]); | 105 EXPECT_FALSE([ns_window isVisible]); |
103 window->ShowWithApp(); | 106 window->ShowWithApp(); |
104 EXPECT_TRUE([ns_window isVisible]); | 107 EXPECT_TRUE([ns_window isVisible]); |
105 EXPECT_FALSE([other_ns_window isVisible]); | 108 EXPECT_FALSE([other_ns_window isVisible]); |
106 } | 109 } |
OLD | NEW |