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

Side by Side Diff: content/browser/renderer_host/render_widget_host_browsertest.cc

Issue 259523008: Remove RenderWidgetHost::GetSnapshotFromRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: getsnapshotfromrenderer: rm Created 6 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/public/browser/render_view_host.h" 7 #include "content/public/browser/render_view_host.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/common/content_paths.h" 9 #include "content/public/common/content_paths.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h" 11 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/shell/browser/shell.h" 12 #include "content/shell/browser/shell.h"
13 #include "net/base/filename_util.h" 13 #include "net/base/filename_util.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class RenderWidgetHostBrowserTest : public ContentBrowserTest { 18 class RenderWidgetHostBrowserTest : public ContentBrowserTest {
19 public: 19 public:
20 RenderWidgetHostBrowserTest() {} 20 RenderWidgetHostBrowserTest() {}
21 21
22 virtual void SetUpOnMainThread() OVERRIDE { 22 virtual void SetUpOnMainThread() OVERRIDE {
23 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir_)); 23 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir_));
24 } 24 }
25 25
26 void GetSnapshotFromRendererCallback(const base::Closure& quit_closure,
27 bool* snapshot_valid,
28 bool success,
29 const SkBitmap& bitmap) {
30 quit_closure.Run();
31 EXPECT_EQ(success, true);
32
33 const int row_bytes = bitmap.rowBytesAsPixels();
34 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
35 for (int i = 0; i < bitmap.width(); ++i) {
36 for (int j = 0; j < bitmap.height(); ++j) {
37 if (pixels[j * row_bytes + i] != SK_ColorRED) {
38 return;
39 }
40 }
41 }
42 *snapshot_valid = true;
43 }
44
45 protected: 26 protected:
46 base::FilePath test_dir_; 27 base::FilePath test_dir_;
47 }; 28 };
48 29
49 // Disabled on Aura since this is not possible with ubercomp.
50 #if defined(USE_AURA)
51 #define MAYBE_GetSnapshotFromRendererTest DISABLED_GetSnapshotFromRendererTest
52 #else
53 #define MAYBE_GetSnapshotFromRendererTest GetSnapshotFromRendererTest
54 #endif
55 IN_PROC_BROWSER_TEST_F(RenderWidgetHostBrowserTest,
56 MAYBE_GetSnapshotFromRendererTest) {
57 base::RunLoop run_loop;
58
59 NavigateToURL(shell(), GURL(net::FilePathToFileURL(
60 test_dir_.AppendASCII("rwh_simple.html"))));
61
62 bool snapshot_valid = false;
63 RenderViewHost* const rwh = shell()->web_contents()->GetRenderViewHost();
64 rwh->GetSnapshotFromRenderer(gfx::Rect(), base::Bind(
65 &RenderWidgetHostBrowserTest::GetSnapshotFromRendererCallback,
66 base::Unretained(this),
67 run_loop.QuitClosure(),
68 &snapshot_valid));
69 run_loop.Run();
70
71 EXPECT_EQ(snapshot_valid, true);
72 }
73
74 } // namespace content 30 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698