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

Side by Side Diff: chrome/browser/thumbnails/render_widget_snapshot_taker_unittest.cc

Issue 154083008: Remove Tabpose feature on mac, and supporting infrastructure (PaintAtSize) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, merge Created 6 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
6
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8
9 class RenderWidgetSnapshotTakerTest : public ChromeRenderViewHostTestHarness {
10 public:
11 RenderWidgetSnapshotTakerTest() : snapshot_ready_called_(false) {}
12
13 void SnapshotReady(const SkBitmap& bitmap) {
14 snapshot_ready_called_ = true;
15 }
16
17 bool snapshot_ready_called() const {
18 return snapshot_ready_called_;
19 }
20
21 private:
22 bool snapshot_ready_called_;
23 };
24
25 #if defined(USE_X11)
26 // RenderWidgetHost::AskForSnapshot is not implemented for X11
27 // (http://crbug.com/89777).
28 #define MAYBE_WidgetDidReceivePaintAtSizeAck \
29 DISABLED_WidgetDidReceivePaintAtSizeAck
30 #else
31 #define MAYBE_WidgetDidReceivePaintAtSizeAck WidgetDidReceivePaintAtSizeAck
32 #endif
33
34 // Just checks the callback runs in WidgetDidReceivePaintAtSizeAck.
35 TEST_F(RenderWidgetSnapshotTakerTest, MAYBE_WidgetDidReceivePaintAtSizeAck) {
36 RenderWidgetSnapshotTaker snapshot_taker;
37 const gfx::Size size(100, 100);
38 snapshot_taker.AskForSnapshot(
39 rvh(),
40 base::Bind(&RenderWidgetSnapshotTakerTest::SnapshotReady,
41 base::Unretained(this)),
42 size,
43 size);
44 EXPECT_EQ(1U, snapshot_taker.callback_map_.size());
45 const int sequence_num = 1;
46 snapshot_taker.WidgetDidReceivePaintAtSizeAck(
47 content::RenderViewHostTestHarness::rvh(),
48 sequence_num,
49 size);
50 EXPECT_TRUE(snapshot_taker.callback_map_.empty());
51 EXPECT_TRUE(snapshot_ready_called());
52 }
53
54 #if defined(USE_X11)
55 // RenderWidgetHost::AskForSnapshot is not implemented for X11
56 // (http://crbug.com/89777).
57 #define MAYBE_WidgetDidReceivePaintAtSizeAckFail \
58 DISABLED_WidgetDidReceivePaintAtSizeAckFail
59 #else
60 #define MAYBE_WidgetDidReceivePaintAtSizeAckFail \
61 WidgetDidReceivePaintAtSizeAckFail
62 #endif
63
64 // Checks the case where RenderWidgetSnapshotTaker receives an ack with a wrong
65 // size. The should result in a failure and the callback should not be called.
66 TEST_F(RenderWidgetSnapshotTakerTest,
67 MAYBE_WidgetDidReceivePaintAtSizeAckFail) {
68 RenderWidgetSnapshotTaker snapshot_taker;
69 const gfx::Size size(100, 100);
70 snapshot_taker.AskForSnapshot(
71 rvh(),
72 base::Bind(&RenderWidgetSnapshotTakerTest::SnapshotReady,
73 base::Unretained(this)),
74 size,
75 size);
76 EXPECT_EQ(1U, snapshot_taker.callback_map_.size());
77 const int sequence_num = 1;
78 // Ensure this is bigger than the max scale factor X the size.
79 const gfx::Size size2(300, 300);
80 snapshot_taker.WidgetDidReceivePaintAtSizeAck(
81 content::RenderViewHostTestHarness::rvh(),
82 sequence_num,
83 size2);
84 EXPECT_FALSE(snapshot_taker.callback_map_.empty());
85 EXPECT_FALSE(snapshot_ready_called());
86 }
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/render_widget_snapshot_taker.cc ('k') | chrome/browser/thumbnails/thumbnail_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698