| 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 #include "webkit/glue/plugins/test/plugin_window_size_test.h" | 5 #include "webkit/glue/plugins/test/plugin_window_size_test.h" |
| 6 #include "webkit/glue/plugins/test/plugin_client.h" | 6 #include "webkit/glue/plugins/test/plugin_client.h" |
| 7 | 7 |
| 8 namespace NPAPIClient { | 8 namespace NPAPIClient { |
| 9 | 9 |
| 10 PluginWindowSizeTest::PluginWindowSizeTest(NPP id, | 10 PluginWindowSizeTest::PluginWindowSizeTest(NPP id, |
| 11 NPNetscapeFuncs *host_functions) | 11 NPNetscapeFuncs *host_functions) |
| 12 : PluginTest(id, host_functions) { | 12 : PluginTest(id, host_functions) { |
| 13 } | 13 } |
| 14 | 14 |
| 15 NPError PluginWindowSizeTest::SetWindow(NPWindow* pNPWindow) { | 15 NPError PluginWindowSizeTest::SetWindow(NPWindow* pNPWindow) { |
| 16 if (!pNPWindow || | 16 HWND window = reinterpret_cast<HWND>(pNPWindow->window); |
| 17 !::IsWindow(reinterpret_cast<HWND>(pNPWindow->window))) { | 17 if (!pNPWindow || !::IsWindow(window)) { |
| 18 SetError("Invalid arguments passed in"); | 18 SetError("Invalid arguments passed in"); |
| 19 return NPERR_INVALID_PARAM; | 19 return NPERR_INVALID_PARAM; |
| 20 } | 20 } |
| 21 | 21 |
| 22 RECT window_rect = {0}; | 22 RECT window_rect = {0}; |
| 23 window_rect.left = pNPWindow->x; | 23 window_rect.left = pNPWindow->x; |
| 24 window_rect.top = pNPWindow->y; | 24 window_rect.top = pNPWindow->y; |
| 25 window_rect.right = pNPWindow->width; | 25 window_rect.right = pNPWindow->width; |
| 26 window_rect.bottom = pNPWindow->height; | 26 window_rect.bottom = pNPWindow->height; |
| 27 | 27 |
| 28 if (!::IsRectEmpty(&window_rect)) { | 28 if (!::IsRectEmpty(&window_rect)) { |
| 29 RECT client_rect = {0}; | 29 RECT client_rect = {0}; |
| 30 ::GetClientRect(reinterpret_cast<HWND>(pNPWindow->window), | 30 ::GetClientRect(window, &client_rect); |
| 31 &client_rect); | |
| 32 if (::IsRectEmpty(&client_rect)) { | 31 if (::IsRectEmpty(&client_rect)) { |
| 33 SetError("The client rect of the plugin window is empty. Test failed"); | 32 SetError("The client rect of the plugin window is empty. Test failed"); |
| 34 } | 33 } |
| 35 | 34 |
| 35 // Bug 6742: ensure that the coordinates passed in are relative to the |
| 36 // parent HWND. |
| 37 POINT origin_from_os; |
| 38 RECT window_rect_from_os; |
| 39 ::GetWindowRect(window, &window_rect_from_os); |
| 40 origin_from_os.x = window_rect_from_os.left; |
| 41 origin_from_os.y = window_rect_from_os.top; |
| 42 ::ScreenToClient(GetParent(window), &origin_from_os); |
| 43 if (origin_from_os.x != pNPWindow->x || origin_from_os.y != pNPWindow->y) |
| 44 SetError("Wrong position passed in to SetWindow! Test failed"); |
| 45 |
| 36 SignalTestCompleted(); | 46 SignalTestCompleted(); |
| 37 } | 47 } |
| 38 | 48 |
| 39 return NPERR_NO_ERROR; | 49 return NPERR_NO_ERROR; |
| 40 } | 50 } |
| 41 | 51 |
| 42 } // namespace NPAPIClient | 52 } // namespace NPAPIClient |
| OLD | NEW |