OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #define STRSAFE_NO_DEPRECATE | 5 #define STRSAFE_NO_DEPRECATE |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "webkit/glue/plugins/test/plugin_windowless_test.h" | 7 #include "webkit/glue/plugins/test/plugin_windowless_test.h" |
8 #include "webkit/glue/plugins/test/plugin_client.h" | 8 #include "webkit/glue/plugins/test/plugin_client.h" |
9 | 9 |
10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 double window_x, window_y; | 201 double window_x, window_y; |
202 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, | 202 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, |
203 &window_x, &window_y, NPCoordinateSpaceWindow); | 203 &window_x, &window_y, NPCoordinateSpaceWindow); |
204 double flipped_window_x, flipped_window_y; | 204 double flipped_window_x, flipped_window_y; |
205 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, | 205 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, |
206 &flipped_window_x, &flipped_window_y, | 206 &flipped_window_x, &flipped_window_y, |
207 NPCoordinateSpaceFlippedWindow); | 207 NPCoordinateSpaceFlippedWindow); |
208 | 208 |
209 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); | 209 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); |
210 | 210 |
211 // Check that all the coordinates are right. The plugin is in a 600x600 window | 211 // Check that all the coordinates are right. The constants below are based on |
212 // at (100, 100), with a content area origin of (100, 100). | 212 // the window frame set in the UI test and the content offset in the test |
213 // Y-coordinates are not checked exactly so that the test is robust against | 213 // html. Y-coordinates are not checked exactly so that the test is robust |
214 // toolbar changes, info bar visibility, etc. | 214 // against toolbar changes, info and bookmark bar visibility, etc. |
| 215 const int kWindowHeight = 400; |
| 216 const int kWindowXOrigin = 50; |
| 217 const int kWindowYOrigin = 50; |
| 218 const int kPluginXContentOffset = 50; |
| 219 const int kPluginYContentOffset = 50; |
| 220 const int kChromeYTolerance = 200; |
| 221 |
215 std::string error_string; | 222 std::string error_string; |
216 if (screen_x != flipped_screen_x) | 223 if (screen_x != flipped_screen_x) |
217 error_string = "Flipping screen coordinates shouldn't change x"; | 224 error_string = "Flipping screen coordinates shouldn't change x"; |
218 else if (flipped_screen_y != main_display_bounds.size.height - screen_y) | 225 else if (flipped_screen_y != main_display_bounds.size.height - screen_y) |
219 error_string = "Flipped screen coordinates should be flipped vertically"; | 226 error_string = "Flipped screen coordinates should be flipped vertically"; |
220 else if (screen_x != 200) | 227 else if (screen_x != kWindowXOrigin + kPluginXContentOffset) |
221 error_string = "Screen x location is wrong"; | 228 error_string = "Screen x location is wrong"; |
222 else if (flipped_screen_y < 200 || flipped_screen_y > 400) | 229 else if (flipped_screen_y < kWindowYOrigin + kPluginYContentOffset || |
| 230 flipped_screen_y > kWindowYOrigin + kPluginYContentOffset + |
| 231 kChromeYTolerance) |
223 error_string = "Screen y location is wrong"; | 232 error_string = "Screen y location is wrong"; |
224 else if (window_x != flipped_window_x) | 233 else if (window_x != flipped_window_x) |
225 error_string = "Flipping window coordinates shouldn't change x"; | 234 error_string = "Flipping window coordinates shouldn't change x"; |
226 else if (flipped_window_y != 600 - window_y) | 235 else if (flipped_window_y != kWindowHeight - window_y) |
227 error_string = "Flipped window coordinates should be flipped vertically"; | 236 error_string = "Flipped window coordinates should be flipped vertically"; |
228 else if (window_x != 100) | 237 else if (window_x != kPluginXContentOffset) |
229 error_string = "Window x location is wrong"; | 238 error_string = "Window x location is wrong"; |
230 else if (flipped_screen_y < 100 || flipped_screen_y > 300) | 239 else if (flipped_window_y < kPluginYContentOffset || |
| 240 flipped_window_y > kPluginYContentOffset + kChromeYTolerance) |
231 error_string = "Window y location is wrong"; | 241 error_string = "Window y location is wrong"; |
232 | 242 |
233 if (!error_string.empty()) { | 243 if (!error_string.empty()) { |
234 error_string.append(" - "); | 244 error_string.append(" - "); |
235 error_string.append(StringForPoint(screen_x, screen_y)); | 245 error_string.append(StringForPoint(screen_x, screen_y)); |
236 error_string.append(" - "); | 246 error_string.append(" - "); |
237 error_string.append(StringForPoint(flipped_screen_x, flipped_screen_y)); | 247 error_string.append(StringForPoint(flipped_screen_x, flipped_screen_y)); |
238 error_string.append(" - "); | 248 error_string.append(" - "); |
239 error_string.append(StringForPoint(window_x, window_y)); | 249 error_string.append(StringForPoint(window_x, window_y)); |
240 error_string.append(" - "); | 250 error_string.append(" - "); |
241 error_string.append(StringForPoint(flipped_window_x, flipped_window_y)); | 251 error_string.append(StringForPoint(flipped_window_x, flipped_window_y)); |
242 SetError(error_string); | 252 SetError(error_string); |
243 } | 253 } |
244 #else | 254 #else |
245 SetError("Unimplemented"); | 255 SetError("Unimplemented"); |
246 #endif | 256 #endif |
247 SignalTestCompleted(); | 257 SignalTestCompleted(); |
248 } | 258 } |
249 | 259 |
250 } // namespace NPAPIClient | 260 } // namespace NPAPIClient |
OLD | NEW |