OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/codec/jpeg_codec.h" | 5 #include "app/gfx/codec/jpeg_codec.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "chrome/common/native_web_keyboard_event.h" | 8 #include "chrome/common/native_web_keyboard_event.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/renderer/print_web_view_helper.h" | 10 #include "chrome/renderer/print_web_view_helper.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 const int kMaxOutputCharacters = 16; | 303 const int kMaxOutputCharacters = 16; |
304 std::wstring output = UTF16ToWideHack( | 304 std::wstring output = UTF16ToWideHack( |
305 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 305 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
306 EXPECT_EQ(output, kTextDirection[i].expected_result); | 306 EXPECT_EQ(output, kTextDirection[i].expected_result); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 // Tests that printing pages work and sending and receiving messages through | 310 // Tests that printing pages work and sending and receiving messages through |
311 // that channel all works. | 311 // that channel all works. |
312 TEST_F(RenderViewTest, OnPrintPages) { | 312 TEST_F(RenderViewTest, OnPrintPages) { |
313 #if defined(OS_WIN) | 313 #if defined(OS_WIN) || defined(OS_MACOSX) |
314 // Lets simulate a print pages with Hello world. | 314 // Lets simulate a print pages with Hello world. |
315 LoadHTML("<body><p>Hello World!</p></body>"); | 315 LoadHTML("<body><p>Hello World!</p></body>"); |
316 view_->OnPrintPages(); | 316 view_->OnPrintPages(); |
317 | 317 |
318 // The renderer should be done calculating the number of rendered pages | 318 // The renderer should be done calculating the number of rendered pages |
319 // according to the specified settings defined in the mock render thread. | 319 // according to the specified settings defined in the mock render thread. |
320 // Verify the page count is correct. | 320 // Verify the page count is correct. |
321 const IPC::Message* page_cnt_msg = | 321 const IPC::Message* page_cnt_msg = |
322 render_thread_.sink().GetUniqueMessageMatching( | 322 render_thread_.sink().GetUniqueMessageMatching( |
323 ViewHostMsg_DidGetPrintedPagesCount::ID); | 323 ViewHostMsg_DidGetPrintedPagesCount::ID); |
(...skipping 11 matching lines...) Expand all Loading... |
335 ViewHostMsg_DidPrintPage::Param post_did_print_page_param; | 335 ViewHostMsg_DidPrintPage::Param post_did_print_page_param; |
336 ViewHostMsg_DidPrintPage::Read(did_print_msg, &post_did_print_page_param); | 336 ViewHostMsg_DidPrintPage::Read(did_print_msg, &post_did_print_page_param); |
337 EXPECT_EQ(0, post_did_print_page_param.a.page_number); | 337 EXPECT_EQ(0, post_did_print_page_param.a.page_number); |
338 #else | 338 #else |
339 NOTIMPLEMENTED(); | 339 NOTIMPLEMENTED(); |
340 #endif | 340 #endif |
341 } | 341 } |
342 | 342 |
343 // Duplicate of OnPrintPagesTest only using javascript to print. | 343 // Duplicate of OnPrintPagesTest only using javascript to print. |
344 TEST_F(RenderViewTest, PrintWithJavascript) { | 344 TEST_F(RenderViewTest, PrintWithJavascript) { |
345 #if defined(OS_WIN) | 345 #if defined(OS_WIN) || defined(OS_MACOSX) |
346 // HTML contains a call to window.print() | 346 // HTML contains a call to window.print() |
347 LoadHTML("<body>Hello<script>window.print()</script>World</body>"); | 347 LoadHTML("<body>Hello<script>window.print()</script>World</body>"); |
348 | 348 |
349 // The renderer should be done calculating the number of rendered pages | 349 // The renderer should be done calculating the number of rendered pages |
350 // according to the specified settings defined in the mock render thread. | 350 // according to the specified settings defined in the mock render thread. |
351 // Verify the page count is correct. | 351 // Verify the page count is correct. |
352 const IPC::Message* page_cnt_msg = | 352 const IPC::Message* page_cnt_msg = |
353 render_thread_.sink().GetUniqueMessageMatching( | 353 render_thread_.sink().GetUniqueMessageMatching( |
354 ViewHostMsg_DidGetPrintedPagesCount::ID); | 354 ViewHostMsg_DidGetPrintedPagesCount::ID); |
355 ASSERT_TRUE(page_cnt_msg); | 355 ASSERT_TRUE(page_cnt_msg); |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 WebURLError error; | 904 WebURLError error; |
905 error.domain.fromUTF8("test_domain"); | 905 error.domain.fromUTF8("test_domain"); |
906 error.reason = net::ERR_ABORTED; | 906 error.reason = net::ERR_ABORTED; |
907 error.unreachableURL = GURL("http://foo"); | 907 error.unreachableURL = GURL("http://foo"); |
908 WebFrame* web_frame = GetMainFrame(); | 908 WebFrame* web_frame = GetMainFrame(); |
909 // A cancellation occurred. | 909 // A cancellation occurred. |
910 view_->didFailProvisionalLoad(web_frame, error); | 910 view_->didFailProvisionalLoad(web_frame, error); |
911 // Frame should stay in view-source mode. | 911 // Frame should stay in view-source mode. |
912 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 912 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
913 } | 913 } |
OLD | NEW |