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

Side by Side Diff: services/ui/public/cpp/tests/window_tree_client_unittest.cc

Issue 2447303002: Scale client area, hit test mask and bounds by device_scale_factor. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 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 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 "services/ui/public/cpp/window_tree_client.h" 5 #include "services/ui/public/cpp/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "mojo/common/common_type_converters.h" 11 #include "mojo/common/common_type_converters.h"
12 #include "services/ui/common/util.h" 12 #include "services/ui/common/util.h"
13 #include "services/ui/public/cpp/input_event_handler.h" 13 #include "services/ui/public/cpp/input_event_handler.h"
14 #include "services/ui/public/cpp/property_type_converters.h" 14 #include "services/ui/public/cpp/property_type_converters.h"
15 #include "services/ui/public/cpp/tests/test_window.h" 15 #include "services/ui/public/cpp/tests/test_window.h"
16 #include "services/ui/public/cpp/tests/test_window_tree.h" 16 #include "services/ui/public/cpp/tests/test_window_tree.h"
17 #include "services/ui/public/cpp/tests/window_tree_client_private.h" 17 #include "services/ui/public/cpp/tests/window_tree_client_private.h"
18 #include "services/ui/public/cpp/window.h" 18 #include "services/ui/public/cpp/window.h"
19 #include "services/ui/public/cpp/window_observer.h" 19 #include "services/ui/public/cpp/window_observer.h"
20 #include "services/ui/public/cpp/window_private.h" 20 #include "services/ui/public/cpp/window_private.h"
21 #include "services/ui/public/cpp/window_property.h" 21 #include "services/ui/public/cpp/window_property.h"
22 #include "services/ui/public/cpp/window_tracker.h" 22 #include "services/ui/public/cpp/window_tracker.h"
23 #include "services/ui/public/cpp/window_tree_client_delegate.h" 23 #include "services/ui/public/cpp/window_tree_client_delegate.h"
24 #include "services/ui/public/cpp/window_tree_client_observer.h" 24 #include "services/ui/public/cpp/window_tree_client_observer.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/display/test/test_screen.h"
26 #include "ui/events/event.h" 27 #include "ui/events/event.h"
27 #include "ui/events/event_utils.h" 28 #include "ui/events/event_utils.h"
28 #include "ui/gfx/geometry/rect.h" 29 #include "ui/gfx/geometry/rect.h"
29 30
30 namespace ui { 31 namespace ui {
31 32
32 namespace { 33 namespace {
33 34
34 void DoNothingWithEventResult(mojom::EventResult result) {} 35 void DoNothingWithEventResult(mojom::EventResult result) {}
35 36
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 69
69 private: 70 private:
70 std::unique_ptr<ui::PointerEvent> last_event_observed_; 71 std::unique_ptr<ui::PointerEvent> last_event_observed_;
71 72
72 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientDelegate); 73 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientDelegate);
73 }; 74 };
74 75
75 class WindowTreeSetup { 76 class WindowTreeSetup {
76 public: 77 public:
77 WindowTreeSetup() : tree_client_(&window_tree_delegate_, nullptr, nullptr) { 78 WindowTreeSetup() : tree_client_(&window_tree_delegate_, nullptr, nullptr) {
79 display::Screen::SetScreenInstance(&test_screen_);
78 WindowTreeClientPrivate(&tree_client_).OnEmbed(&window_tree_); 80 WindowTreeClientPrivate(&tree_client_).OnEmbed(&window_tree_);
79 window_tree_.GetAndClearChangeId(nullptr); 81 window_tree_.GetAndClearChangeId(nullptr);
80 } 82 }
81 83
84 ~WindowTreeSetup() { display::Screen::SetScreenInstance(nullptr); }
85
82 WindowTreeClient* client() { 86 WindowTreeClient* client() {
83 return &tree_client_; 87 return &tree_client_;
84 } 88 }
85 89
86 mojom::WindowTreeClient* window_tree_client() { 90 mojom::WindowTreeClient* window_tree_client() {
87 return static_cast<mojom::WindowTreeClient*>(&tree_client_); 91 return static_cast<mojom::WindowTreeClient*>(&tree_client_);
88 } 92 }
89 93
90 TestWindowTree* window_tree() { return &window_tree_; } 94 TestWindowTree* window_tree() { return &window_tree_; }
91 95
92 TestWindowTreeClientDelegate* window_tree_delegate() { 96 TestWindowTreeClientDelegate* window_tree_delegate() {
93 return &window_tree_delegate_; 97 return &window_tree_delegate_;
94 } 98 }
95 99
96 Window* GetFirstRoot() { 100 Window* GetFirstRoot() {
97 return client()->GetRoots().empty() ? nullptr 101 return client()->GetRoots().empty() ? nullptr
98 : *client()->GetRoots().begin(); 102 : *client()->GetRoots().begin();
99 } 103 }
100 104
101 private: 105 private:
102 TestWindowTree window_tree_; 106 TestWindowTree window_tree_;
103 TestWindowTreeClientDelegate window_tree_delegate_; 107 TestWindowTreeClientDelegate window_tree_delegate_;
104 WindowTreeClient tree_client_; 108 WindowTreeClient tree_client_;
105 109
110 // Dummy screen required to be the screen instance.
111 display::test::TestScreen test_screen_;
112
106 DISALLOW_COPY_AND_ASSIGN(WindowTreeSetup); 113 DISALLOW_COPY_AND_ASSIGN(WindowTreeSetup);
107 }; 114 };
108 115
109 class TestInputEventHandler : public InputEventHandler { 116 class TestInputEventHandler : public InputEventHandler {
110 public: 117 public:
111 TestInputEventHandler() 118 TestInputEventHandler()
112 : received_event_(false), should_manually_ack_(false) {} 119 : received_event_(false), should_manually_ack_(false) {}
113 ~TestInputEventHandler() override {} 120 ~TestInputEventHandler() override {}
114 121
115 void set_should_manually_ack() { should_manually_ack_ = true; } 122 void set_should_manually_ack() { should_manually_ack_ = true; }
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1083
1077 // Changes originating from server should notify observers too. 1084 // Changes originating from server should notify observers too.
1078 WindowTreeClientPrivate(setup.client()).CallOnCaptureChanged(child2, nullptr); 1085 WindowTreeClientPrivate(setup.client()).CallOnCaptureChanged(child2, nullptr);
1079 EXPECT_EQ(1, capture_recorder.capture_changed_count()); 1086 EXPECT_EQ(1, capture_recorder.capture_changed_count());
1080 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id()); 1087 EXPECT_EQ(child2_id, capture_recorder.last_gained_capture_window_id());
1081 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id()); 1088 EXPECT_EQ(0, capture_recorder.last_lost_capture_window_id());
1082 capture_recorder.reset_capture_captured_count(); 1089 capture_recorder.reset_capture_captured_count();
1083 } 1090 }
1084 1091
1085 } // namespace ui 1092 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/tests/window_server_test_base.cc ('k') | services/ui/public/cpp/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698