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

Side by Side Diff: trunk/src/ui/aura/root_window_host_x11_unittest.cc

Issue 77203002: Revert 236048 "Rename RootWindowHost* to WindowTreeHost*" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/ui/aura/root_window_host_x11.cc ('k') | trunk/src/ui/aura/root_window_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 5
6 #include "base/sys_info.h" 6 #include "base/sys_info.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/aura/root_window_host_x11.h" 9 #include "ui/aura/root_window_host_x11.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
11 #include "ui/aura/window_tree_host_delegate.h" 11 #include "ui/aura/window_tree_host_delegate.h"
12 #include "ui/events/x/events_x_utils.h" 12 #include "ui/events/x/events_x_utils.h"
13 13
14 namespace { 14 namespace {
15 class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate { 15 class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate {
16 public: 16 public:
17 TestWindowTreeHostDelegate() : last_touch_type_(ui::ET_UNKNOWN), 17 TestRootWindowHostDelegate() : last_touch_type_(ui::ET_UNKNOWN),
18 last_touch_id_(-1), 18 last_touch_id_(-1),
19 last_touch_location_(0, 0) { 19 last_touch_location_(0, 0) {
20 } 20 }
21 virtual ~TestWindowTreeHostDelegate() {} 21 virtual ~TestRootWindowHostDelegate() {}
22 22
23 virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE { 23 virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE {
24 return true; 24 return true;
25 } 25 }
26 26
27 virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE { 27 virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE {
28 return true; 28 return true;
29 } 29 }
30 virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE { 30 virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE {
31 return true; 31 return true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 gfx::Point last_touch_location() { 71 gfx::Point last_touch_location() {
72 return last_touch_location_; 72 return last_touch_location_;
73 } 73 }
74 74
75 private: 75 private:
76 ui::EventType last_touch_type_; 76 ui::EventType last_touch_type_;
77 int last_touch_id_; 77 int last_touch_id_;
78 gfx::Point last_touch_location_; 78 gfx::Point last_touch_location_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostDelegate); 80 DISALLOW_COPY_AND_ASSIGN(TestRootWindowHostDelegate);
81 }; 81 };
82 82
83 } // namespace 83 } // namespace
84 84
85 namespace aura { 85 namespace aura {
86 86
87 typedef test::AuraTestBase WindowTreeHostX11Test; 87 typedef test::AuraTestBase RootWindowHostX11Test;
88 88
89 // Send X touch events to one WindowTreeHost. The WindowTreeHost's 89 // Send X touch events to one RootWindowHost. The RootWindowHost's
90 // delegate will get corresponding ui::TouchEvent if the touch events 90 // delegate will get corresponding ui::TouchEvent if the touch events
91 // are winthin the bound of the WindowTreeHost. 91 // are winthin the bound of the RootWindowHost.
92 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { 92 TEST_F(RootWindowHostX11Test, DispatchTouchEventToOneRootWindow) {
93 #if defined(OS_CHROMEOS) 93 #if defined(OS_CHROMEOS)
94 // Fake a ChromeOS running env. 94 // Fake a ChromeOS running env.
95 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; 95 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
96 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 96 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
97 #endif // defined(OS_CHROMEOS) 97 #endif // defined(OS_CHROMEOS)
98 98
99 scoped_ptr<WindowTreeHostX11> root_window_host( 99 scoped_ptr<RootWindowHostX11> root_window_host(
100 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); 100 new RootWindowHostX11(gfx::Rect(0, 0, 2560, 1700)));
101 scoped_ptr<TestWindowTreeHostDelegate> delegate( 101 scoped_ptr<TestRootWindowHostDelegate> delegate(
102 new TestWindowTreeHostDelegate()); 102 new TestRootWindowHostDelegate());
103 root_window_host->set_delegate(delegate.get()); 103 root_window_host->set_delegate(delegate.get());
104 104
105 std::vector<unsigned int> devices; 105 std::vector<unsigned int> devices;
106 devices.push_back(0); 106 devices.push_back(0);
107 ui::SetupTouchDevicesForTest(devices); 107 ui::SetupTouchDevicesForTest(devices);
108 std::vector<ui::Valuator> valuators; 108 std::vector<ui::Valuator> valuators;
109 109
110 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); 110 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type());
111 EXPECT_EQ(-1, delegate->last_touch_id()); 111 EXPECT_EQ(-1, delegate->last_touch_id());
112 112
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Revert the CrOS testing env otherwise the following non-CrOS aura 145 // Revert the CrOS testing env otherwise the following non-CrOS aura
146 // tests will fail. 146 // tests will fail.
147 #if defined(OS_CHROMEOS) 147 #if defined(OS_CHROMEOS)
148 // Fake a ChromeOS running env. 148 // Fake a ChromeOS running env.
149 kLsbRelease = ""; 149 kLsbRelease = "";
150 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 150 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
151 #endif // defined(OS_CHROMEOS) 151 #endif // defined(OS_CHROMEOS)
152 } 152 }
153 153
154 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is 154 // Send X touch events to two RootWindowHost. The RootWindowHost which is
155 // the event target of the X touch events should generate the corresponding 155 // the event target of the X touch events should generate the corresponding
156 // ui::TouchEvent for its delegate. 156 // ui::TouchEvent for its delegate.
157 #if defined(OS_CHROMEOS) 157 #if defined(OS_CHROMEOS)
158 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { 158 TEST_F(RootWindowHostX11Test, DispatchTouchEventToTwoRootWindow) {
159 // Fake a ChromeOS running env. 159 // Fake a ChromeOS running env.
160 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; 160 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
161 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 161 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
162 162
163 scoped_ptr<WindowTreeHostX11> root_window_host1( 163 scoped_ptr<RootWindowHostX11> root_window_host1(
164 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); 164 new RootWindowHostX11(gfx::Rect(0, 0, 2560, 1700)));
165 scoped_ptr<TestWindowTreeHostDelegate> delegate1( 165 scoped_ptr<TestRootWindowHostDelegate> delegate1(
166 new TestWindowTreeHostDelegate()); 166 new TestRootWindowHostDelegate());
167 root_window_host1->set_delegate(delegate1.get()); 167 root_window_host1->set_delegate(delegate1.get());
168 168
169 int host2_y_offset = 1700; 169 int host2_y_offset = 1700;
170 scoped_ptr<WindowTreeHostX11> root_window_host2( 170 scoped_ptr<RootWindowHostX11> root_window_host2(
171 new WindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); 171 new RootWindowHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080)));
172 scoped_ptr<TestWindowTreeHostDelegate> delegate2( 172 scoped_ptr<TestRootWindowHostDelegate> delegate2(
173 new TestWindowTreeHostDelegate()); 173 new TestRootWindowHostDelegate());
174 root_window_host2->set_delegate(delegate2.get()); 174 root_window_host2->set_delegate(delegate2.get());
175 175
176 std::vector<unsigned int> devices; 176 std::vector<unsigned int> devices;
177 devices.push_back(0); 177 devices.push_back(0);
178 ui::SetupTouchDevicesForTest(devices); 178 ui::SetupTouchDevicesForTest(devices);
179 std::vector<ui::Valuator> valuators; 179 std::vector<ui::Valuator> valuators;
180 180
181 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); 181 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type());
182 EXPECT_EQ(-1, delegate1->last_touch_id()); 182 EXPECT_EQ(-1, delegate1->last_touch_id());
183 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); 183 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type());
184 EXPECT_EQ(-1, delegate2->last_touch_id()); 184 EXPECT_EQ(-1, delegate2->last_touch_id());
185 185
186 // 2 Touch events are targeted at the second WindowTreeHost. 186 // 2 Touch events are targeted at the second RootWindowHost.
187 ui::XScopedTouchEvent touch1_begin(ui::CreateTouchEvent( 187 ui::XScopedTouchEvent touch1_begin(ui::CreateTouchEvent(
188 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators)); 188 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators));
189 root_window_host1->Dispatch(touch1_begin); 189 root_window_host1->Dispatch(touch1_begin);
190 root_window_host2->Dispatch(touch1_begin); 190 root_window_host2->Dispatch(touch1_begin);
191 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); 191 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type());
192 EXPECT_EQ(-1, delegate1->last_touch_id()); 192 EXPECT_EQ(-1, delegate1->last_touch_id());
193 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); 193 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location());
194 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); 194 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type());
195 EXPECT_EQ(0, delegate2->last_touch_id()); 195 EXPECT_EQ(0, delegate2->last_touch_id());
196 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), 196 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 // Revert the CrOS testing env otherwise the following non-CrOS aura 259 // Revert the CrOS testing env otherwise the following non-CrOS aura
260 // tests will fail. 260 // tests will fail.
261 // Fake a ChromeOS running env. 261 // Fake a ChromeOS running env.
262 kLsbRelease = ""; 262 kLsbRelease = "";
263 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 263 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
264 } 264 }
265 #endif // defined(OS_CHROMEOS) 265 #endif // defined(OS_CHROMEOS)
266 266
267 } // namespace aura 267 } // namespace aura
OLDNEW
« no previous file with comments | « trunk/src/ui/aura/root_window_host_x11.cc ('k') | trunk/src/ui/aura/root_window_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698