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

Side by Side Diff: chrome/renderer/render_view_unittest.cc

Issue 243076: Move the JPEG and PNG codecs from base/gfx to app/gfx/codec. Move the classes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 6 #include "base/file_util.h"
6 #include "base/gfx/jpeg_codec.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"
11 #include "chrome/test/render_view_test.h" 11 #include "chrome/test/render_view_test.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "printing/image.h" 13 #include "printing/image.h"
14 #include "printing/native_metafile.h" 14 #include "printing/native_metafile.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webkit/api/public/WebString.h" 16 #include "webkit/api/public/WebString.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 page_params.page_number = 0; 511 page_params.page_number = 0;
512 512
513 // Fetch the image data from the web frame. 513 // Fetch the image data from the web frame.
514 std::vector<unsigned char> data; 514 std::vector<unsigned char> data;
515 view_->print_helper()->PrintPageAsJPEG(page_params, 515 view_->print_helper()->PrintPageAsJPEG(page_params,
516 view_->webview()->mainFrame(), 516 view_->webview()->mainFrame(),
517 1.0f, 517 1.0f,
518 &data); 518 &data);
519 std::vector<unsigned char> decoded; 519 std::vector<unsigned char> decoded;
520 int w, h; 520 int w, h;
521 EXPECT_TRUE(JPEGCodec::Decode(&data[0], data.size(), JPEGCodec::FORMAT_RGBA, 521 EXPECT_TRUE(gfx::JPEGCodec::Decode(&data[0], data.size(),
522 &decoded, &w, &h)); 522 gfx::JPEGCodec::FORMAT_RGBA,
523 &decoded, &w, &h));
523 524
524 // Check if its not 100% white. 525 // Check if its not 100% white.
525 bool is_white = true; 526 bool is_white = true;
526 for (int y = 0; y < h; y++) { 527 for (int y = 0; y < h; y++) {
527 for (int x = 0; x < w; x++) { 528 for (int x = 0; x < w; x++) {
528 unsigned char* px = &decoded[(y * w + x) * 4]; 529 unsigned char* px = &decoded[(y * w + x) * 4];
529 if (px[0] != 0xFF && px[1] != 0xFF && px[2] != 0xFF) { 530 if (px[0] != 0xFF && px[1] != 0xFF && px[2] != 0xFF) {
530 is_white = false; 531 is_white = false;
531 break; 532 break;
532 } 533 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 WebURLError error; 904 WebURLError error;
904 error.domain.fromUTF8("test_domain"); 905 error.domain.fromUTF8("test_domain");
905 error.reason = net::ERR_ABORTED; 906 error.reason = net::ERR_ABORTED;
906 error.unreachableURL = GURL("http://foo"); 907 error.unreachableURL = GURL("http://foo");
907 WebFrame* web_frame = GetMainFrame(); 908 WebFrame* web_frame = GetMainFrame();
908 // A cancellation occurred. 909 // A cancellation occurred.
909 view_->didFailProvisionalLoad(web_frame, error); 910 view_->didFailProvisionalLoad(web_frame, error);
910 // Frame should stay in view-source mode. 911 // Frame should stay in view-source mode.
911 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 912 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
912 } 913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698