Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / apps / native_app_window_cocoa_browsertest.mm
blob9b203a8573f31e51724e191ea01745fd18e94e01
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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
7 #import <Cocoa/Cocoa.h>
9 #include "apps/shell_window_registry.h"
10 #include "chrome/browser/apps/app_browsertest_util.h"
11 #include "chrome/browser/ui/extensions/application_launch.h"
12 #include "content/public/browser/notification_service.h"
13 #include "content/public/test/test_utils.h"
15 using extensions::PlatformAppBrowserTest;
17 namespace {
19 class NativeAppWindowCocoaBrowserTest : public PlatformAppBrowserTest {
20  protected:
21   NativeAppWindowCocoaBrowserTest() {}
23   void SetUpAppWithWindows(int num_windows) {
24     app_ = InstallExtension(
25         test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"), 1);
26     EXPECT_TRUE(app_);
28     for (int i = 0; i < num_windows; ++i) {
29       content::WindowedNotificationObserver app_loaded_observer(
30           content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
31           content::NotificationService::AllSources());
32       chrome::OpenApplication(chrome::AppLaunchParams(
33           profile(), app_, extension_misc::LAUNCH_NONE, NEW_WINDOW));
34       app_loaded_observer.Wait();
35     }
36   }
38   const extensions::Extension* app_;
40  private:
41   DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoaBrowserTest);
44 }  // namespace
46 // Test interaction of Hide/Show() with Hide/ShowWithApp().
47 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, HideShowWithApp) {
48   SetUpAppWithWindows(2);
49   apps::ShellWindowRegistry::ShellWindowList windows =
50       apps::ShellWindowRegistry::Get(profile())->shell_windows();
51   apps::NativeAppWindow* window = windows.front()->GetBaseWindow();
52   NSWindow* ns_window = window->GetNativeWindow();
53   apps::NativeAppWindow* other_window = windows.back()->GetBaseWindow();
54   NSWindow* other_ns_window = other_window->GetNativeWindow();
56   // Normal Hide/Show.
57   window->Hide();
58   EXPECT_FALSE([ns_window isVisible]);
59   window->Show();
60   EXPECT_TRUE([ns_window isVisible]);
62   // Normal Hide/ShowWithApp.
63   window->HideWithApp();
64   EXPECT_FALSE([ns_window isVisible]);
65   window->ShowWithApp();
66   EXPECT_TRUE([ns_window isVisible]);
68   // HideWithApp, Hide, ShowWithApp does not show.
69   window->HideWithApp();
70   window->Hide();
71   window->ShowWithApp();
72   EXPECT_FALSE([ns_window isVisible]);
74   // Hide, HideWithApp, ShowWithApp does not show.
75   window->HideWithApp();
76   window->ShowWithApp();
77   EXPECT_FALSE([ns_window isVisible]);
79   // Return to shown state.
80   window->Show();
81   EXPECT_TRUE([ns_window isVisible]);
83   // HideWithApp the other window.
84   EXPECT_TRUE([other_ns_window isVisible]);
85   other_window->HideWithApp();
86   EXPECT_FALSE([other_ns_window isVisible]);
88   // HideWithApp, Show shows all windows for this app.
89   window->HideWithApp();
90   EXPECT_FALSE([ns_window isVisible]);
91   window->Show();
92   EXPECT_TRUE([ns_window isVisible]);
93   EXPECT_TRUE([other_ns_window isVisible]);
95   // Hide the other window.
96   other_window->Hide();
97   EXPECT_FALSE([other_ns_window isVisible]);
99   // HideWithApp, ShowWithApp does not show the other window.
100   window->HideWithApp();
101   EXPECT_FALSE([ns_window isVisible]);
102   window->ShowWithApp();
103   EXPECT_TRUE([ns_window isVisible]);
104   EXPECT_FALSE([other_ns_window isVisible]);