Index: chrome/browser/ui/views/apps/chrome_native_app_window_views_mac_browsertest.mm |
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac_browsertest.mm b/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac_browsertest.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e3f8c5c8562bf3703bfd02bceb915599bf33206d |
--- /dev/null |
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac_browsertest.mm |
@@ -0,0 +1,117 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.h" |
+ |
+#import <Cocoa/Cocoa.h> |
+ |
+#include "base/mac/mac_util.h" |
+#include "base/mac/sdk_forward_declarations.h" |
+#include "chrome/browser/apps/app_browsertest_util.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/extensions/app_launch_params.h" |
+#include "chrome/browser/ui/extensions/application_launch.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/test/test_utils.h" |
+#include "extensions/browser/app_window/app_window_registry.h" |
+#include "extensions/common/constants.h" |
+ |
+namespace { |
+ |
+class ChromeNativeAppWindowViewsMacBrowserTest |
+ : public extensions::PlatformAppBrowserTest { |
+ protected: |
+ ChromeNativeAppWindowViewsMacBrowserTest() {} |
+ |
+ void SetUpAppWithWindows(int num_windows) { |
+ app_ = InstallExtension( |
+ test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"), 1); |
+ EXPECT_TRUE(app_); |
+ |
+ for (int i = 0; i < num_windows; ++i) { |
+ content::WindowedNotificationObserver app_loaded_observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ OpenApplication( |
+ AppLaunchParams(profile(), app_, extensions::LAUNCH_CONTAINER_NONE, |
+ NEW_WINDOW, extensions::SOURCE_TEST)); |
+ app_loaded_observer.Wait(); |
+ } |
+ } |
+ |
+ const extensions::Extension* app_; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViewsMacBrowserTest); |
+}; |
+ |
+} // namespace |
+ |
+// Test interaction of Hide/Show() with Hide/ShowWithApp(). |
+IN_PROC_BROWSER_TEST_F(ChromeNativeAppWindowViewsMacBrowserTest, |
+ HideShowWithApp) { |
+ SetUpAppWithWindows(2); |
+ extensions::AppWindowRegistry::AppWindowList windows = |
+ extensions::AppWindowRegistry::Get(profile())->app_windows(); |
+ |
+ extensions::AppWindow* app_window = windows.front(); |
+ extensions::NativeAppWindow* native_window = app_window->GetBaseWindow(); |
+ NSWindow* ns_window = native_window->GetNativeWindow(); |
+EXPECT_TRUE(ns_window); |
tapted
2015/03/04 02:27:33
indenting is weird here
jackhou1
2015/03/04 03:34:55
Just using native_app_window_cocoa_browsertest.mm
|
+ extensions::AppWindow* other_app_window = windows.back(); |
+ extensions::NativeAppWindow* other_native_window = |
+ other_app_window->GetBaseWindow(); |
+ NSWindow* other_ns_window = other_native_window->GetNativeWindow(); |
+EXPECT_TRUE(other_ns_window); |
+ |
+ // Normal Hide/Show. |
+ app_window->Hide(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ app_window->Show(extensions::AppWindow::SHOW_ACTIVE); |
+ EXPECT_TRUE([ns_window isVisible]); |
+ |
+ // Normal Hide/ShowWithApp. |
+ native_window->HideWithApp(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ native_window->ShowWithApp(); |
+ EXPECT_TRUE([ns_window isVisible]); |
+ |
+ // HideWithApp, Hide, ShowWithApp does not show. |
+ native_window->HideWithApp(); |
+ app_window->Hide(); |
+ native_window->ShowWithApp(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ |
+ // Hide, HideWithApp, ShowWithApp does not show. |
+ native_window->HideWithApp(); |
+ native_window->ShowWithApp(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ |
+ // Return to shown state. |
+ app_window->Show(extensions::AppWindow::SHOW_ACTIVE); |
+ EXPECT_TRUE([ns_window isVisible]); |
+ |
+ // HideWithApp the other window. |
+ EXPECT_TRUE([other_ns_window isVisible]); |
+ other_native_window->HideWithApp(); |
+ EXPECT_FALSE([other_ns_window isVisible]); |
+ |
+ // HideWithApp, Show shows all windows for this app. |
+ native_window->HideWithApp(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ app_window->Show(extensions::AppWindow::SHOW_ACTIVE); |
+ EXPECT_TRUE([ns_window isVisible]); |
+ EXPECT_TRUE([other_ns_window isVisible]); |
+ |
+ // Hide the other window. |
+ other_app_window->Hide(); |
+ EXPECT_FALSE([other_ns_window isVisible]); |
+ |
+ // HideWithApp, ShowWithApp does not show the other window. |
+ native_window->HideWithApp(); |
+ EXPECT_FALSE([ns_window isVisible]); |
+ native_window->ShowWithApp(); |
+ EXPECT_TRUE([ns_window isVisible]); |
+ EXPECT_FALSE([other_ns_window isVisible]); |
+} |