OLD | NEW |
1 // Copyright (c) 2010 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 "chrome/test/render_view_test.h" | 5 #include "chrome/test/render_view_test.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
8 #include "chrome/common/dom_storage_common.h" | 8 #include "chrome/common/dom_storage_common.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/native_web_keyboard_event.h" | 10 #include "chrome/common/native_web_keyboard_event.h" |
11 #include "chrome/common/render_messages.h" | 11 #include "chrome/common/render_messages.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 void RenderViewTest::SendNativeKeyEvent( | 253 void RenderViewTest::SendNativeKeyEvent( |
254 const NativeWebKeyboardEvent& key_event) { | 254 const NativeWebKeyboardEvent& key_event) { |
255 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); | 255 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); |
256 input_message->WriteData(reinterpret_cast<const char*>(&key_event), | 256 input_message->WriteData(reinterpret_cast<const char*>(&key_event), |
257 sizeof(WebKit::WebKeyboardEvent)); | 257 sizeof(WebKit::WebKeyboardEvent)); |
258 view_->OnMessageReceived(*input_message); | 258 view_->OnMessageReceived(*input_message); |
259 } | 259 } |
260 | 260 |
261 void RenderViewTest::VerifyPageCount(int count) { | 261 void RenderViewTest::VerifyPageCount(int count) { |
262 #if defined(OS_WIN) || defined(OS_MACOSX) | 262 #if defined(OS_CHROMEOS) |
| 263 // The DidGetPrintedPagesCount message isn't sent on ChromeOS. Right now we |
| 264 // always print all pages, and there are checks to that effect built into |
| 265 // the print code. |
| 266 #else |
263 const IPC::Message* page_cnt_msg = | 267 const IPC::Message* page_cnt_msg = |
264 render_thread_.sink().GetUniqueMessageMatching( | 268 render_thread_.sink().GetUniqueMessageMatching( |
265 ViewHostMsg_DidGetPrintedPagesCount::ID); | 269 ViewHostMsg_DidGetPrintedPagesCount::ID); |
266 ASSERT_TRUE(page_cnt_msg); | 270 ASSERT_TRUE(page_cnt_msg); |
267 ViewHostMsg_DidGetPrintedPagesCount::Param post_page_count_param; | 271 ViewHostMsg_DidGetPrintedPagesCount::Param post_page_count_param; |
268 ViewHostMsg_DidGetPrintedPagesCount::Read(page_cnt_msg, | 272 ViewHostMsg_DidGetPrintedPagesCount::Read(page_cnt_msg, |
269 &post_page_count_param); | 273 &post_page_count_param); |
270 EXPECT_EQ(count, post_page_count_param.b); | 274 EXPECT_EQ(count, post_page_count_param.b); |
271 #elif defined(OS_LINUX) | 275 #endif // defined(OS_CHROMEOS) |
272 // The DidGetPrintedPagesCount message isn't sent on Linux. Right now we | |
273 // always print all pages, and there are checks to that effect built into | |
274 // the print code. | |
275 #endif | |
276 } | 276 } |
277 | 277 |
278 void RenderViewTest::VerifyPagesPrinted() { | 278 void RenderViewTest::VerifyPagesPrinted() { |
279 #if defined(OS_WIN) || defined(OS_MACOSX) | 279 #if defined(OS_CHROMEOS) |
| 280 const IPC::Message* did_print_msg = |
| 281 render_thread_.sink().GetUniqueMessageMatching( |
| 282 ViewHostMsg_TempFileForPrintingWritten::ID); |
| 283 ASSERT_TRUE(did_print_msg); |
| 284 #else |
280 const IPC::Message* did_print_msg = | 285 const IPC::Message* did_print_msg = |
281 render_thread_.sink().GetUniqueMessageMatching( | 286 render_thread_.sink().GetUniqueMessageMatching( |
282 ViewHostMsg_DidPrintPage::ID); | 287 ViewHostMsg_DidPrintPage::ID); |
283 ASSERT_TRUE(did_print_msg); | 288 ASSERT_TRUE(did_print_msg); |
284 ViewHostMsg_DidPrintPage::Param post_did_print_page_param; | 289 ViewHostMsg_DidPrintPage::Param post_did_print_page_param; |
285 ViewHostMsg_DidPrintPage::Read(did_print_msg, &post_did_print_page_param); | 290 ViewHostMsg_DidPrintPage::Read(did_print_msg, &post_did_print_page_param); |
286 EXPECT_EQ(0, post_did_print_page_param.a.page_number); | 291 EXPECT_EQ(0, post_did_print_page_param.a.page_number); |
287 #elif defined(OS_LINUX) | 292 #endif // defined(OS_CHROMEOS) |
288 const IPC::Message* did_print_msg = | |
289 render_thread_.sink().GetUniqueMessageMatching( | |
290 ViewHostMsg_TempFileForPrintingWritten::ID); | |
291 ASSERT_TRUE(did_print_msg); | |
292 #endif | |
293 } | 293 } |
294 | 294 |
295 const char* const kGetCoordinatesScript = | 295 const char* const kGetCoordinatesScript = |
296 "(function() {" | 296 "(function() {" |
297 " function GetCoordinates(elem) {" | 297 " function GetCoordinates(elem) {" |
298 " if (!elem)" | 298 " if (!elem)" |
299 " return [ 0, 0];" | 299 " return [ 0, 0];" |
300 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" | 300 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" |
301 " var parent_coordinates = GetCoordinates(elem.offsetParent);" | 301 " var parent_coordinates = GetCoordinates(elem.offsetParent);" |
302 " coordinates[0] += parent_coordinates[0];" | 302 " coordinates[0] += parent_coordinates[0];" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 mouse_event.x = bounds.CenterPoint().x(); | 347 mouse_event.x = bounds.CenterPoint().x(); |
348 mouse_event.y = bounds.CenterPoint().y(); | 348 mouse_event.y = bounds.CenterPoint().y(); |
349 mouse_event.clickCount = 1; | 349 mouse_event.clickCount = 1; |
350 ViewMsg_HandleInputEvent input_event(0); | 350 ViewMsg_HandleInputEvent input_event(0); |
351 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); | 351 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); |
352 input_message->WriteData(reinterpret_cast<const char*>(&mouse_event), | 352 input_message->WriteData(reinterpret_cast<const char*>(&mouse_event), |
353 sizeof(WebMouseEvent)); | 353 sizeof(WebMouseEvent)); |
354 view_->OnMessageReceived(*input_message); | 354 view_->OnMessageReceived(*input_message); |
355 return true; | 355 return true; |
356 } | 356 } |
OLD | NEW |