OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "apps/ui/native_app_window.h" | |
6 #include "chrome/browser/apps/app_browsertest_util.h" | |
7 #include "chrome/browser/extensions/extension_test_message_listener.h" | |
8 #include "chrome/test/base/interactive_test_utils.h" | |
9 | |
10 using namespace apps; | |
11 | |
12 // Helper class that has to be created in the stack to check if the fullscreen | |
13 // setting of a NativeWindow has changed since the creation of the object. | |
14 class FullscreenChangeHelper { | |
15 public: | |
16 explicit FullscreenChangeHelper(NativeAppWindow* window) | |
17 : window_(window) | |
18 , initial_fullscreen_state_(window_->IsFullscreen()) | |
koz (OOO until 15th September)
2013/11/19 07:29:57
nit: commas go on previous lines and variables lin
| |
19 , already_changed_(false) | |
20 {} | |
koz (OOO until 15th September)
2013/11/19 07:29:57
nit: curlies should look like
already_chang
| |
21 | |
22 bool DidFullscreenChanged() { | |
23 if (already_changed_) | |
24 return true; | |
25 | |
26 if (initial_fullscreen_state_ != window_->IsFullscreen()) { | |
27 already_changed_ = true; | |
28 return true; | |
29 } | |
30 | |
31 return false; | |
32 } | |
33 | |
34 private: | |
35 NativeAppWindow* window_; | |
36 bool initial_fullscreen_state_; | |
koz (OOO until 15th September)
2013/11/19 07:29:57
nit: should only be one space between type and var
| |
37 bool already_changed_; | |
38 }; | |
39 | |
40 class AppInteractiveTest : public extensions::PlatformAppBrowserTest { | |
41 }; | |
42 | |
43 IN_PROC_BROWSER_TEST_F(AppInteractiveTest, ESCLeavesFullscreenWindow) { | |
44 ExtensionTestMessageListener launched_listener("Launched", true); | |
45 LoadAndLaunchPlatformApp("leave_fullscreen"); | |
46 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | |
47 | |
48 launched_listener.Reply("window"); | |
49 | |
50 { | |
51 FullscreenChangeHelper fs_changed(GetFirstShellWindow()->GetBaseWindow()); | |
52 | |
53 while (!fs_changed.DidFullscreenChanged()) | |
54 content::RunAllPendingInMessageLoop(); | |
koz (OOO until 15th September)
2013/11/19 07:29:57
If we have the app send a message after it goes in
| |
55 } | |
56 | |
57 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
58 GetFirstShellWindow()->GetNativeWindow(), ui::VKEY_ESCAPE, | |
59 false, false, false, false)); | |
60 | |
61 { | |
62 FullscreenChangeHelper fs_changed(GetFirstShellWindow()->GetBaseWindow()); | |
63 | |
64 while (!fs_changed.DidFullscreenChanged()) | |
65 content::RunAllPendingInMessageLoop(); | |
66 } | |
67 } | |
68 | |
69 IN_PROC_BROWSER_TEST_F(AppInteractiveTest, ESCLeavesFullscreenDOM) { | |
70 ExtensionTestMessageListener launched_listener("Launched", true); | |
71 LoadAndLaunchPlatformApp("leave_fullscreen"); | |
72 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | |
73 | |
74 launched_listener.Reply("dom"); | |
75 | |
76 // Because the DOM way to go fullscreen requires user gesture, we simulate a | |
77 // key event to get the window entering in fullscreen mode. The reply will | |
78 // make the window listen for the key event. The reply will be sent to the | |
79 // renderer process such as the key event so they should arrive in the same | |
koz (OOO until 15th September)
2013/11/19 07:29:57
"renderer process before the keypress and should b
| |
80 // order. | |
81 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
82 GetFirstShellWindow()->GetNativeWindow(), ui::VKEY_A, | |
83 false, false, false, false)); | |
84 | |
85 { | |
86 FullscreenChangeHelper fs_changed(GetFirstShellWindow()->GetBaseWindow()); | |
87 | |
88 while (!fs_changed.DidFullscreenChanged()) | |
89 content::RunAllPendingInMessageLoop(); | |
90 } | |
91 | |
92 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
93 GetFirstShellWindow()->GetNativeWindow(), ui::VKEY_ESCAPE, | |
94 false, false, false, false)); | |
95 | |
96 { | |
97 FullscreenChangeHelper fs_changed(GetFirstShellWindow()->GetBaseWindow()); | |
98 | |
99 while (!fs_changed.DidFullscreenChanged()) | |
100 content::RunAllPendingInMessageLoop(); | |
101 } | |
102 } | |
OLD | NEW |