From 507b33eab2acbb4e360b5b6eb9f2e666079d0e3b Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Tue, 29 Sep 2009 03:56:51 +0000 Subject: Fix cmd-up/cmd-down. The approach is to special-case moveToBeginningOfDocument and moveToEndOfDocument in WebFrameImpl::executeCommand(). With this (and the cocoa keyboard bindings patch being landed), the special-case code in WebViewImpl::ScrollViewWithKeyboard() can be removed. Also add a test for cmd-up/down. Change chrome.gyp so that it supports osx-only unit tests (_unittest_mac.mm). Move OnPrintPageAsBitmap to the other printing tests. BUG=22585 TEST=Go to a page with both text box and scrollbar (e.g. http://en.wikipedia.org ). Pressing cmd-down should scroll to end of page, cmd-up back to start. Clicking the text box and trying some emacs shortcuts should work (ctrl-a jumps to start of line, cmd-h acts as backspace, etc). Review URL: http://codereview.chromium.org/254002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27464 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/render_view_unittest.cc | 84 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'chrome/renderer/render_view_unittest.cc') diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index 5e10179..3119996 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -496,6 +496,48 @@ TEST_F(RenderViewTest, PrintLayoutTest) { #endif } +// Print page as bitmap test. +TEST_F(RenderViewTest, OnPrintPageAsBitmap) { +#if defined(OS_WIN) + // Lets simulate a print pages with Hello world. + LoadHTML("

Hello world!

"); + + // Grab the printer settings from the printer. + ViewMsg_Print_Params print_settings; + MockPrinter* printer(render_thread_.printer()); + printer->GetDefaultPrintSettings(&print_settings); + ViewMsg_PrintPage_Params page_params = ViewMsg_PrintPage_Params(); + page_params.params = print_settings; + page_params.page_number = 0; + + // Fetch the image data from the web frame. + std::vector data; + view_->print_helper()->PrintPageAsJPEG(page_params, + view_->webview()->GetMainFrame(), + 1.0f, + &data); + std::vector decoded; + int w, h; + EXPECT_TRUE(JPEGCodec::Decode(&data[0], data.size(), JPEGCodec::FORMAT_RGBA, + &decoded, &w, &h)); + + // Check if its not 100% white. + bool is_white = true; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + unsigned char* px = &decoded[(y * w + x) * 4]; + if (px[0] != 0xFF && px[1] != 0xFF && px[2] != 0xFF) { + is_white = false; + break; + } + } + } + ASSERT_TRUE(!is_white); +#else + NOTIMPLEMENTED(); +#endif +} + // Test that we can receive correct DOM events when we send input events // through the RenderWidget::OnHandleInputEvent() function. TEST_F(RenderViewTest, OnHandleKeyboardEvent) { @@ -868,45 +910,3 @@ TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForCancellation) { // Frame should stay in view-source mode. EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); } - -// Print page as bitmap test. -TEST_F(RenderViewTest, OnPrintPageAsBitmap) { -#if defined(OS_WIN) - // Lets simulate a print pages with Hello world. - LoadHTML("

Hello world!

"); - - // Grab the printer settings from the printer. - ViewMsg_Print_Params print_settings; - MockPrinter* printer(render_thread_.printer()); - printer->GetDefaultPrintSettings(&print_settings); - ViewMsg_PrintPage_Params page_params = ViewMsg_PrintPage_Params(); - page_params.params = print_settings; - page_params.page_number = 0; - - // Fetch the image data from the web frame. - std::vector data; - view_->print_helper()->PrintPageAsJPEG(page_params, - view_->webview()->GetMainFrame(), - 1.0f, - &data); - std::vector decoded; - int w, h; - EXPECT_TRUE(JPEGCodec::Decode(&data[0], data.size(), JPEGCodec::FORMAT_RGBA, - &decoded, &w, &h)); - - // Check if its not 100% white. - bool is_white = true; - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - unsigned char* px = &decoded[(y * w + x) * 4]; - if (px[0] != 0xFF && px[1] != 0xFF && px[2] != 0xFF) { - is_white = false; - break; - } - } - } - ASSERT_TRUE(!is_white); -#else - NOTIMPLEMENTED(); -#endif -} -- cgit v1.1