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

Side by Side Diff: blimp/client/session/tab_control_feature_unittest.cc

Issue 1636163002: Restructure contents of blimp/client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « blimp/client/session/tab_control_feature_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "blimp/client/session/tab_control_feature.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "blimp/common/proto/blimp_message.pb.h"
10 #include "blimp/common/proto/tab_control.pb.h"
11 #include "blimp/net/test_common.h"
12 #include "net/base/net_errors.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/geometry/size.h"
16
17 using testing::_;
18
19 namespace blimp {
20 namespace client {
21
22 MATCHER_P3(EqualsSizeMessage, width, height, dp_to_px, "") {
23 return arg.tab_control().type() == TabControlMessage::SIZE &&
24 arg.tab_control().size().width() == width &&
25 arg.tab_control().size().height() == height &&
26 arg.tab_control().size().device_pixel_ratio() == dp_to_px;
27 }
28
29 class TabControlFeatureTest : public testing::Test {
30 public:
31 TabControlFeatureTest() : out_processor_(nullptr) {}
32
33 void SetUp() override {
34 out_processor_ = new MockBlimpMessageProcessor();
35 feature_.set_outgoing_message_processor(make_scoped_ptr(out_processor_));
36 }
37
38 protected:
39 // This is a raw pointer to a class that is owned by the ControlFeature.
40 MockBlimpMessageProcessor* out_processor_;
41
42 TabControlFeature feature_;
43 };
44
45 TEST_F(TabControlFeatureTest, CreatesCorrectSizeMessage) {
46 uint64_t width = 10;
47 uint64_t height = 15;
48 float dp_to_px = 1.23f;
49
50 EXPECT_CALL(
51 *out_processor_,
52 MockableProcessMessage(EqualsSizeMessage(width, height, dp_to_px), _))
53 .Times(1);
54 feature_.SetSizeAndScale(gfx::Size(width, height), dp_to_px);
55 }
56
57 TEST_F(TabControlFeatureTest, NoDuplicateSizeMessage) {
58 uint64_t width = 10;
59 uint64_t height = 15;
60 float dp_to_px = 1.23f;
61
62 EXPECT_CALL(
63 *out_processor_,
64 MockableProcessMessage(EqualsSizeMessage(width, height, dp_to_px), _))
65 .Times(1)
66 .RetiresOnSaturation();
67 EXPECT_CALL(
68 *out_processor_,
69 MockableProcessMessage(EqualsSizeMessage(width, height, dp_to_px + 1), _))
70 .Times(1)
71 .RetiresOnSaturation();
72 EXPECT_CALL(*out_processor_,
73 MockableProcessMessage(
74 EqualsSizeMessage(width + 1, height, dp_to_px + 1), _))
75 .Times(1)
76 .RetiresOnSaturation();
77 EXPECT_CALL(*out_processor_,
78 MockableProcessMessage(
79 EqualsSizeMessage(width + 1, height + 1, dp_to_px + 1), _))
80 .Times(1)
81 .RetiresOnSaturation();
82
83 feature_.SetSizeAndScale(gfx::Size(width, height), dp_to_px);
84 feature_.SetSizeAndScale(gfx::Size(width, height), dp_to_px);
85 feature_.SetSizeAndScale(gfx::Size(width, height), dp_to_px + 1);
86 feature_.SetSizeAndScale(gfx::Size(width + 1, height), dp_to_px + 1);
87 feature_.SetSizeAndScale(gfx::Size(width + 1, height + 1), dp_to_px + 1);
88 }
89
90 } // namespace client
91 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/session/tab_control_feature_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698