OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_fullscreen.h" | 5 #include "ppapi/tests/test_fullscreen.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (screen_mode_.IsFullscreen()) | 78 if (screen_mode_.IsFullscreen()) |
79 return ReportError("IsFullscreen() at start", true); | 79 return ReportError("IsFullscreen() at start", true); |
80 | 80 |
81 // 1. Switch to fullscreen. | 81 // 1. Switch to fullscreen. |
82 // This is only allowed within a context of a user gesture (e.g. mouse click). | 82 // This is only allowed within a context of a user gesture (e.g. mouse click). |
83 if (screen_mode_.SetFullscreen(true)) | 83 if (screen_mode_.SetFullscreen(true)) |
84 return ReportError("SetFullscreen(true) outside of user gesture", true); | 84 return ReportError("SetFullscreen(true) outside of user gesture", true); |
85 // The transition is asynchronous and ends at the next DidChangeView(). | 85 // The transition is asynchronous and ends at the next DidChangeView(). |
86 // No graphics devices can be bound while in transition. | 86 // No graphics devices can be bound while in transition. |
87 instance_->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 87 instance_->RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
| 88 SimulateUserGesture(); |
88 // HandleInputEvent() will call SetFullscreen(true). | 89 // HandleInputEvent() will call SetFullscreen(true). |
89 // DidChangeView() will call the callback once in fullscreen mode. | 90 // DidChangeView() will call the callback once in fullscreen mode. |
90 fullscreen_callback_.WaitForResult(); | 91 fullscreen_callback_.WaitForResult(); |
91 if (GotError()) | 92 if (GotError()) |
92 return Error(); | 93 return Error(); |
93 if (fullscreen_pending_) | 94 if (fullscreen_pending_) |
94 return "fullscreen_pending_ has not been reset"; | 95 return "fullscreen_pending_ has not been reset"; |
95 if (!screen_mode_.IsFullscreen()) | 96 if (!screen_mode_.IsFullscreen()) |
96 return ReportError("IsFullscreen() in fullscreen", false); | 97 return ReportError("IsFullscreen() in fullscreen", false); |
97 if (!instance_->BindGraphics(graphics2d_fullscreen_)) | 98 if (!instance_->BindGraphics(graphics2d_fullscreen_)) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 // 4. Stay in normal. No change. | 131 // 4. Stay in normal. No change. |
131 if (screen_mode_.SetFullscreen(false)) | 132 if (screen_mode_.SetFullscreen(false)) |
132 return ReportError("SetFullscreen(false) in normal", true); | 133 return ReportError("SetFullscreen(false) in normal", true); |
133 if (screen_mode_.IsFullscreen()) | 134 if (screen_mode_.IsFullscreen()) |
134 return ReportError("IsFullscreen() in normal^2", true); | 135 return ReportError("IsFullscreen() in normal^2", true); |
135 | 136 |
136 PASS(); | 137 PASS(); |
137 } | 138 } |
138 | 139 |
| 140 void TestFullscreen::SimulateUserGesture() { |
| 141 pp::Point plugin_center( |
| 142 normal_position_.x() + normal_position_.width() / 2, |
| 143 normal_position_.y() + normal_position_.height() / 2); |
| 144 pp::Point mouse_movement; |
| 145 pp::MouseInputEvent input_event( |
| 146 instance_, |
| 147 PP_INPUTEVENT_TYPE_MOUSEDOWN, |
| 148 0, // time_stamp |
| 149 0, // modifiers |
| 150 PP_INPUTEVENT_MOUSEBUTTON_LEFT, |
| 151 plugin_center, |
| 152 1, // click_count |
| 153 mouse_movement); |
| 154 |
| 155 testing_interface_->SimulateInputEvent(instance_->pp_instance(), |
| 156 input_event.pp_resource()); |
| 157 } |
| 158 |
139 void TestFullscreen::FailFullscreenTest(const std::string& error) { | 159 void TestFullscreen::FailFullscreenTest(const std::string& error) { |
140 screen_mode_.SetFullscreen(false); | 160 screen_mode_.SetFullscreen(false); |
141 fullscreen_pending_ = false; | 161 fullscreen_pending_ = false; |
142 error_ = error; | 162 error_ = error; |
143 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); | 163 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); |
144 } | 164 } |
145 | 165 |
146 // Transition to fullscreen can only happen when processing a user gesture. | 166 // Transition to fullscreen can only happen when processing a user gesture. |
147 bool TestFullscreen::HandleInputEvent(const pp::InputEvent& event) { | 167 bool TestFullscreen::HandleInputEvent(const pp::InputEvent& event) { |
148 // We only let mouse events through and only mouse clicks count. | 168 // We only let mouse events through and only mouse clicks count. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); | 237 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); |
218 } else if (normal_pending_) { | 238 } else if (normal_pending_) { |
219 normal_pending_ = false; | 239 normal_pending_ = false; |
220 if (screen_mode_.IsFullscreen()) | 240 if (screen_mode_.IsFullscreen()) |
221 error_ = "DidChangeview is in fullscreen"; | 241 error_ = "DidChangeview is in fullscreen"; |
222 else if (position != normal_position_) | 242 else if (position != normal_position_) |
223 error_ = "DidChangeView position is not normal"; | 243 error_ = "DidChangeView position is not normal"; |
224 pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_); | 244 pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_); |
225 } | 245 } |
226 } | 246 } |
OLD | NEW |