Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: webkit/glue/plugins/test/plugin_windowless_test.cc

Issue 2101008: Improve failure logging for NPN_ConvertPoint test (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/glue/plugins/test/plugin_windowless_test.h" 7 #include "webkit/glue/plugins/test/plugin_windowless_test.h"
7 #include "webkit/glue/plugins/test/plugin_client.h" 8 #include "webkit/glue/plugins/test/plugin_client.h"
8 9
9 #if defined(OS_MACOSX) 10 #if defined(OS_MACOSX)
10 #include <ApplicationServices/ApplicationServices.h> 11 #include <ApplicationServices/ApplicationServices.h>
11 #include <Carbon/Carbon.h> 12 #include <Carbon/Carbon.h>
12 #endif 13 #endif
13 14
14 namespace NPAPIClient { 15 namespace NPAPIClient {
15 16
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 void WindowlessPluginTest::MultipleInstanceSyncCalls(NPNetscapeFuncs* browser) { 142 void WindowlessPluginTest::MultipleInstanceSyncCalls(NPNetscapeFuncs* browser) {
142 if (this == g_other_instance) 143 if (this == g_other_instance)
143 return; 144 return;
144 145
145 DCHECK(g_other_instance); 146 DCHECK(g_other_instance);
146 ExecuteScript(browser, g_other_instance->id(), "TestCallback();", NULL); 147 ExecuteScript(browser, g_other_instance->id(), "TestCallback();", NULL);
147 SignalTestCompleted(); 148 SignalTestCompleted();
148 } 149 }
149 150
151 #if defined(OS_MACOSX)
152 std::string StringForPoint(int x, int y) {
153 std::string point_string("(");
154 point_string.append(IntToString(x));
155 point_string.append(", ");
156 point_string.append(IntToString(y));
157 point_string.append(")");
158 return point_string;
159 }
160 #endif
161
150 void WindowlessPluginTest::ConvertPoint(NPNetscapeFuncs* browser) { 162 void WindowlessPluginTest::ConvertPoint(NPNetscapeFuncs* browser) {
151 #if defined(OS_MACOSX) 163 #if defined(OS_MACOSX)
152 // First, just sanity-test that round trips work. 164 // First, just sanity-test that round trips work.
153 NPCoordinateSpace spaces[] = { NPCoordinateSpacePlugin, 165 NPCoordinateSpace spaces[] = { NPCoordinateSpacePlugin,
154 NPCoordinateSpaceWindow, 166 NPCoordinateSpaceWindow,
155 NPCoordinateSpaceFlippedWindow, 167 NPCoordinateSpaceFlippedWindow,
156 NPCoordinateSpaceScreen, 168 NPCoordinateSpaceScreen,
157 NPCoordinateSpaceFlippedScreen }; 169 NPCoordinateSpaceFlippedScreen };
158 for (unsigned int i = 0; i < arraysize(spaces); ++i) { 170 for (unsigned int i = 0; i < arraysize(spaces); ++i) {
159 for (unsigned int j = 0; j < arraysize(spaces); ++j) { 171 for (unsigned int j = 0; j < arraysize(spaces); ++j) {
160 double x, y, round_trip_x, round_trip_y; 172 double x, y, round_trip_x, round_trip_y;
161 if (!(browser->convertpoint(id(), 0, 0, spaces[i], &x, &y, spaces[j])) || 173 if (!(browser->convertpoint(id(), 0, 0, spaces[i], &x, &y, spaces[j])) ||
162 !(browser->convertpoint(id(), x, y, spaces[j], &round_trip_x, 174 !(browser->convertpoint(id(), x, y, spaces[j], &round_trip_x,
163 &round_trip_y, spaces[i]))) { 175 &round_trip_y, spaces[i]))) {
164 SetError("Conversion failed"); 176 SetError("Conversion failed");
165 SignalTestCompleted(); 177 SignalTestCompleted();
166 return; 178 return;
167 } 179 }
168 if (i != j && x == 0 && y == 0) { 180 if (i != j && x == 0 && y == 0) {
169 SetError("Converting a coordinate should change it"); 181 SetError("Converting a coordinate should change it");
170 SignalTestCompleted(); 182 SignalTestCompleted();
171 return; 183 return;
172 } 184 }
173 if (round_trip_x != 0 || round_trip_y != 0) { 185 if (round_trip_x != 0 || round_trip_y != 0) {
174 SetError("Round-trip conversion should give return the original point"); 186 SetError("Round-trip conversion should return the original point");
175 SignalTestCompleted(); 187 SignalTestCompleted();
176 return; 188 return;
177 } 189 }
178 } 190 }
179 } 191 }
180 192
181 // Now, more extensive testing on a single point. 193 // Now, more extensive testing on a single point.
182 double screen_x, screen_y; 194 double screen_x, screen_y;
183 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, 195 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin,
184 &screen_x, &screen_y, NPCoordinateSpaceScreen); 196 &screen_x, &screen_y, NPCoordinateSpaceScreen);
185 double flipped_screen_x, flipped_screen_y; 197 double flipped_screen_x, flipped_screen_y;
186 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, 198 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin,
187 &flipped_screen_x, &flipped_screen_y, 199 &flipped_screen_x, &flipped_screen_y,
188 NPCoordinateSpaceFlippedScreen); 200 NPCoordinateSpaceFlippedScreen);
189 double window_x, window_y; 201 double window_x, window_y;
190 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, 202 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin,
191 &window_x, &window_y, NPCoordinateSpaceWindow); 203 &window_x, &window_y, NPCoordinateSpaceWindow);
192 double flipped_window_x, flipped_window_y; 204 double flipped_window_x, flipped_window_y;
193 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, 205 browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin,
194 &flipped_window_x, &flipped_window_y, 206 &flipped_window_x, &flipped_window_y,
195 NPCoordinateSpaceFlippedWindow); 207 NPCoordinateSpaceFlippedWindow);
196 208
197 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); 209 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID());
198 210
199 // Check that all the coordinates are right. The plugin is in a 600x600 window 211 // Check that all the coordinates are right. The plugin is in a 600x600 window
200 // at (100, 100), with a content area origin of (100, 100). 212 // at (100, 100), with a content area origin of (100, 100).
201 // Y-coordinates are not checked exactly so that the test is robust against 213 // Y-coordinates are not checked exactly so that the test is robust against
202 // toolbar changes, info bar visibility, etc. 214 // toolbar changes, info bar visibility, etc.
215 std::string error_string;
203 if (screen_x != flipped_screen_x) 216 if (screen_x != flipped_screen_x)
204 SetError("Flipping screen coordinates shouldn't change x"); 217 error_string = "Flipping screen coordinates shouldn't change x";
205 else if (flipped_screen_y != main_display_bounds.size.height - screen_y) 218 else if (flipped_screen_y != main_display_bounds.size.height - screen_y)
206 SetError("Flipped screen coordinates should be flipped vertically!"); 219 error_string = "Flipped screen coordinates should be flipped vertically";
207 else if (screen_x != 200) 220 else if (screen_x != 200)
208 SetError("Screen x location is wrong"); 221 error_string = "Screen x location is wrong";
209 else if (flipped_screen_y < 200 || flipped_screen_y > 400) 222 else if (flipped_screen_y < 200 || flipped_screen_y > 400)
210 SetError("Screen y location is wrong"); 223 error_string = "Screen y location is wrong";
211 if (window_x != flipped_window_x) 224 else if (window_x != flipped_window_x)
212 SetError("Flipping window coordinates shouldn't change x"); 225 error_string = "Flipping window coordinates shouldn't change x";
213 else if (flipped_window_y != 600 - window_y) 226 else if (flipped_window_y != 600 - window_y)
214 SetError("Flipped window coordinates should be flipped vertically!"); 227 error_string = "Flipped window coordinates should be flipped vertically";
215 else if (window_x != 100) 228 else if (window_x != 100)
216 SetError("Window x location is wrong"); 229 error_string = "Window x location is wrong";
217 else if (flipped_screen_y < 100 || flipped_screen_y > 300) 230 else if (flipped_screen_y < 100 || flipped_screen_y > 300)
218 SetError("Window y location is wrong"); 231 error_string = "Window y location is wrong";
232
233 if (!error_string.empty()) {
234 error_string.append(" - ");
235 error_string.append(StringForPoint(screen_x, screen_y));
236 error_string.append(" - ");
237 error_string.append(StringForPoint(flipped_screen_x, flipped_screen_y));
238 error_string.append(" - ");
239 error_string.append(StringForPoint(window_x, window_y));
240 error_string.append(" - ");
241 error_string.append(StringForPoint(flipped_window_x, flipped_window_y));
242 SetError(error_string);
243 }
219 #else 244 #else
220 SetError("Unimplemented"); 245 SetError("Unimplemented");
221 #endif 246 #endif
222 SignalTestCompleted(); 247 SignalTestCompleted();
223 } 248 }
224 249
225 } // namespace NPAPIClient 250 } // namespace NPAPIClient
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698