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

Side by Side Diff: services/ui/display/platform_screen_ozone_unittests.cc

Issue 2356913002: Pass device scale factor from display to ws. (Closed)
Patch Set: Fix more tests. Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 20 matching lines...) Expand all
31 31
32 namespace { 32 namespace {
33 33
34 // The ID of default "display" that gets added when running off device. 34 // The ID of default "display" that gets added when running off device.
35 const int64_t kDefaultDisplayId = 1; 35 const int64_t kDefaultDisplayId = 1;
36 36
37 // Holds info about the display state we want to test. 37 // Holds info about the display state we want to test.
38 struct DisplayState { 38 struct DisplayState {
39 int64_t id; 39 int64_t id;
40 gfx::Rect bounds; 40 gfx::Rect bounds;
41 gfx::Size size;
42 float device_scale_factor;
41 }; 43 };
42 44
43 // Matchers that operate on DisplayState. 45 // Matchers that operate on DisplayState.
44 MATCHER_P(DisplayId, display_id, "") { 46 MATCHER_P(DisplayId, display_id, "") {
45 *result_listener << "has id " << arg.id; 47 *result_listener << "has id " << arg.id;
46 return arg.id == display_id; 48 return arg.id == display_id;
47 } 49 }
48 50
49 MATCHER_P(DisplaySize, size_string, "") { 51 MATCHER_P(DisplaySize, size_string, "") {
50 *result_listener << "has size " << arg.bounds.size().ToString(); 52 *result_listener << "has size " << arg.bounds.size().ToString();
(...skipping 25 matching lines...) Expand all
76 std::vector<DisplayState> removed() { return removed_; } 78 std::vector<DisplayState> removed() { return removed_; }
77 std::vector<DisplayState> modified() { return modified_; } 79 std::vector<DisplayState> modified() { return modified_; }
78 80
79 void Reset() { 81 void Reset() {
80 added_.clear(); 82 added_.clear();
81 removed_.clear(); 83 removed_.clear();
82 modified_.clear(); 84 modified_.clear();
83 } 85 }
84 86
85 private: 87 private:
86 void OnDisplayAdded(int64_t id, const gfx::Rect& bounds) override { 88 void OnDisplayAdded(int64_t id,
87 added_.push_back({id, bounds}); 89 const gfx::Rect& bounds,
90 const gfx::Size& pixel_size,
91 float device_scale_factor) override {
92 added_.push_back({id, bounds, pixel_size, device_scale_factor});
88 } 93 }
89 94
90 void OnDisplayRemoved(int64_t id) override { 95 void OnDisplayRemoved(int64_t id) override {
91 removed_.push_back({id, gfx::Rect()}); 96 removed_.push_back({id, gfx::Rect(), gfx::Size(), 1.0f});
92 } 97 }
93 98
94 void OnDisplayModified(int64_t id, const gfx::Rect& bounds) override { 99 void OnDisplayModified(int64_t id,
95 modified_.push_back({id, bounds}); 100 const gfx::Rect& bounds,
101 const gfx::Size& pixel_size,
102 float device_scale_factor) override {
103 modified_.push_back({id, bounds, pixel_size, device_scale_factor});
96 } 104 }
97 105
98 std::vector<DisplayState> added_; 106 std::vector<DisplayState> added_;
99 std::vector<DisplayState> removed_; 107 std::vector<DisplayState> removed_;
100 std::vector<DisplayState> modified_; 108 std::vector<DisplayState> modified_;
101 109
102 DISALLOW_COPY_AND_ASSIGN(TestPlatformScreenDelegate); 110 DISALLOW_COPY_AND_ASSIGN(TestPlatformScreenDelegate);
103 }; 111 };
104 112
105 // Test fixture with helpers to act like ui::DisplayConfigurator and send 113 // Test fixture with helpers to act like ui::DisplayConfigurator and send
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Check that the default display was modified with a new size and display 2 328 // Check that the default display was modified with a new size and display 2
321 // was modified with a new origin. 329 // was modified with a new origin.
322 ASSERT_THAT(delegate()->modified(), SizeIs(2)); 330 ASSERT_THAT(delegate()->modified(), SizeIs(2));
323 EXPECT_THAT(delegate()->modified()[0], DisplayId(kDefaultDisplayId)); 331 EXPECT_THAT(delegate()->modified()[0], DisplayId(kDefaultDisplayId));
324 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size.ToString())); 332 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size.ToString()));
325 EXPECT_THAT(delegate()->modified()[1], DisplayId(2)); 333 EXPECT_THAT(delegate()->modified()[1], DisplayId(2));
326 EXPECT_THAT(delegate()->modified()[1], DisplayOrigin("1920,0")); 334 EXPECT_THAT(delegate()->modified()[1], DisplayOrigin("1920,0"));
327 } 335 }
328 336
329 } // namespace display 337 } // namespace display
OLDNEW
« no previous file with comments | « services/ui/display/platform_screen_ozone.cc ('k') | services/ui/display/platform_screen_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698