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

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

Issue 126513004: Rename RootWindowHost to WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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
« no previous file with comments | « ui/aura/root_window_host_x11.cc ('k') | 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/event_processor.h" 12 #include "ui/events/event_processor.h"
13 #include "ui/events/event_target.h" 13 #include "ui/events/event_target.h"
14 #include "ui/events/event_target_iterator.h" 14 #include "ui/events/event_target_iterator.h"
15 #include "ui/events/test/events_test_utils_x11.h" 15 #include "ui/events/test/events_test_utils_x11.h"
16 16
17 namespace { 17 namespace {
18 class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate, 18 class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate,
19 public ui::EventProcessor, 19 public ui::EventProcessor,
20 public ui::EventTarget { 20 public ui::EventTarget {
21 public: 21 public:
22 TestRootWindowHostDelegate() : last_touch_type_(ui::ET_UNKNOWN), 22 TestWindowTreeHostDelegate() : last_touch_type_(ui::ET_UNKNOWN),
23 last_touch_id_(-1), 23 last_touch_id_(-1),
24 last_touch_location_(0, 0) { 24 last_touch_location_(0, 0) {
25 } 25 }
26 virtual ~TestRootWindowHostDelegate() {} 26 virtual ~TestWindowTreeHostDelegate() {}
27 27
28 // aura::RootWindowHostDelegate: 28 // aura::WindowTreeHostDelegate:
29 virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE { 29 virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE {
30 return true; 30 return true;
31 } 31 }
32 virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE { 32 virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE {
33 return true; 33 return true;
34 } 34 }
35 virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE { 35 virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE {
36 return true; 36 return true;
37 } 37 }
38 virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE { 38 virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 gfx::Point last_touch_location() { 89 gfx::Point last_touch_location() {
90 return last_touch_location_; 90 return last_touch_location_;
91 } 91 }
92 92
93 private: 93 private:
94 ui::EventType last_touch_type_; 94 ui::EventType last_touch_type_;
95 int last_touch_id_; 95 int last_touch_id_;
96 gfx::Point last_touch_location_; 96 gfx::Point last_touch_location_;
97 ui::EventTargeter targeter_; 97 ui::EventTargeter targeter_;
98 98
99 DISALLOW_COPY_AND_ASSIGN(TestRootWindowHostDelegate); 99 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostDelegate);
100 }; 100 };
101 101
102 } // namespace 102 } // namespace
103 103
104 namespace aura { 104 namespace aura {
105 105
106 typedef test::AuraTestBase RootWindowHostX11Test; 106 typedef test::AuraTestBase WindowTreeHostX11Test;
107 107
108 // Send X touch events to one RootWindowHost. The RootWindowHost's 108 // Send X touch events to one WindowTreeHost. The WindowTreeHost's
109 // delegate will get corresponding ui::TouchEvent if the touch events 109 // delegate will get corresponding ui::TouchEvent if the touch events
110 // are winthin the bound of the RootWindowHost. 110 // are winthin the bound of the WindowTreeHost.
111 TEST_F(RootWindowHostX11Test, DispatchTouchEventToOneRootWindow) { 111 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
112 #if defined(OS_CHROMEOS) 112 #if defined(OS_CHROMEOS)
113 // Fake a ChromeOS running env. 113 // Fake a ChromeOS running env.
114 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; 114 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
115 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 115 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
116 #endif // defined(OS_CHROMEOS) 116 #endif // defined(OS_CHROMEOS)
117 117
118 scoped_ptr<RootWindowHostX11> root_window_host( 118 scoped_ptr<WindowTreeHostX11> root_window_host(
119 new RootWindowHostX11(gfx::Rect(0, 0, 2560, 1700))); 119 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
120 scoped_ptr<TestRootWindowHostDelegate> delegate( 120 scoped_ptr<TestWindowTreeHostDelegate> delegate(
121 new TestRootWindowHostDelegate()); 121 new TestWindowTreeHostDelegate());
122 root_window_host->set_delegate(delegate.get()); 122 root_window_host->set_delegate(delegate.get());
123 123
124 std::vector<unsigned int> devices; 124 std::vector<unsigned int> devices;
125 devices.push_back(0); 125 devices.push_back(0);
126 ui::SetUpTouchDevicesForTest(devices); 126 ui::SetUpTouchDevicesForTest(devices);
127 std::vector<ui::Valuator> valuators; 127 std::vector<ui::Valuator> valuators;
128 128
129 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); 129 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type());
130 EXPECT_EQ(-1, delegate->last_touch_id()); 130 EXPECT_EQ(-1, delegate->last_touch_id());
131 131
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 // Revert the CrOS testing env otherwise the following non-CrOS aura 165 // Revert the CrOS testing env otherwise the following non-CrOS aura
166 // tests will fail. 166 // tests will fail.
167 #if defined(OS_CHROMEOS) 167 #if defined(OS_CHROMEOS)
168 // Fake a ChromeOS running env. 168 // Fake a ChromeOS running env.
169 kLsbRelease = ""; 169 kLsbRelease = "";
170 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 170 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
171 #endif // defined(OS_CHROMEOS) 171 #endif // defined(OS_CHROMEOS)
172 } 172 }
173 173
174 // Send X touch events to two RootWindowHost. The RootWindowHost which is 174 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is
175 // the event target of the X touch events should generate the corresponding 175 // the event target of the X touch events should generate the corresponding
176 // ui::TouchEvent for its delegate. 176 // ui::TouchEvent for its delegate.
177 #if defined(OS_CHROMEOS) 177 #if defined(OS_CHROMEOS)
178 TEST_F(RootWindowHostX11Test, DispatchTouchEventToTwoRootWindow) { 178 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
179 // Fake a ChromeOS running env. 179 // Fake a ChromeOS running env.
180 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; 180 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
181 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 181 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
182 182
183 scoped_ptr<RootWindowHostX11> root_window_host1( 183 scoped_ptr<WindowTreeHostX11> root_window_host1(
184 new RootWindowHostX11(gfx::Rect(0, 0, 2560, 1700))); 184 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
185 scoped_ptr<TestRootWindowHostDelegate> delegate1( 185 scoped_ptr<TestWindowTreeHostDelegate> delegate1(
186 new TestRootWindowHostDelegate()); 186 new TestWindowTreeHostDelegate());
187 root_window_host1->set_delegate(delegate1.get()); 187 root_window_host1->set_delegate(delegate1.get());
188 188
189 int host2_y_offset = 1700; 189 int host2_y_offset = 1700;
190 scoped_ptr<RootWindowHostX11> root_window_host2( 190 scoped_ptr<WindowTreeHostX11> root_window_host2(
191 new RootWindowHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); 191 new WindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080)));
192 scoped_ptr<TestRootWindowHostDelegate> delegate2( 192 scoped_ptr<TestWindowTreeHostDelegate> delegate2(
193 new TestRootWindowHostDelegate()); 193 new TestWindowTreeHostDelegate());
194 root_window_host2->set_delegate(delegate2.get()); 194 root_window_host2->set_delegate(delegate2.get());
195 195
196 std::vector<unsigned int> devices; 196 std::vector<unsigned int> devices;
197 devices.push_back(0); 197 devices.push_back(0);
198 ui::SetUpTouchDevicesForTest(devices); 198 ui::SetUpTouchDevicesForTest(devices);
199 std::vector<ui::Valuator> valuators; 199 std::vector<ui::Valuator> valuators;
200 200
201 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); 201 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type());
202 EXPECT_EQ(-1, delegate1->last_touch_id()); 202 EXPECT_EQ(-1, delegate1->last_touch_id());
203 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); 203 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type());
204 EXPECT_EQ(-1, delegate2->last_touch_id()); 204 EXPECT_EQ(-1, delegate2->last_touch_id());
205 205
206 // 2 Touch events are targeted at the second RootWindowHost. 206 // 2 Touch events are targeted at the second WindowTreeHost.
207 ui::ScopedXI2Event scoped_xevent; 207 ui::ScopedXI2Event scoped_xevent;
208 scoped_xevent.InitTouchEvent( 208 scoped_xevent.InitTouchEvent(
209 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); 209 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators);
210 root_window_host1->Dispatch(scoped_xevent); 210 root_window_host1->Dispatch(scoped_xevent);
211 root_window_host2->Dispatch(scoped_xevent); 211 root_window_host2->Dispatch(scoped_xevent);
212 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); 212 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type());
213 EXPECT_EQ(-1, delegate1->last_touch_id()); 213 EXPECT_EQ(-1, delegate1->last_touch_id());
214 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); 214 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location());
215 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); 215 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type());
216 EXPECT_EQ(0, delegate2->last_touch_id()); 216 EXPECT_EQ(0, delegate2->last_touch_id());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 // Revert the CrOS testing env otherwise the following non-CrOS aura 280 // Revert the CrOS testing env otherwise the following non-CrOS aura
281 // tests will fail. 281 // tests will fail.
282 // Fake a ChromeOS running env. 282 // Fake a ChromeOS running env.
283 kLsbRelease = ""; 283 kLsbRelease = "";
284 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 284 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
285 } 285 }
286 #endif // defined(OS_CHROMEOS) 286 #endif // defined(OS_CHROMEOS)
287 287
288 } // namespace aura 288 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_x11.cc ('k') | ui/aura/root_window_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698