OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/host/ash_window_tree_host_x11.h" | 5 #include "ash/host/ash_window_tree_host_x11.h" |
6 | 6 |
7 #undef None | 7 #undef None |
8 #undef Bool | 8 #undef Bool |
9 | 9 |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 int last_touch_id_; | 50 int last_touch_id_; |
51 gfx::Point last_touch_location_; | 51 gfx::Point last_touch_location_; |
52 | 52 |
53 DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); | 53 DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); |
54 }; | 54 }; |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 namespace ash { | 58 namespace ash { |
59 | 59 |
60 typedef aura::test::AuraTestBase AshWindowTreeHostX11Test; | 60 class AshWindowTreeHostX11Test : public aura::test::AuraTestBase { |
| 61 public: |
| 62 virtual void SetUp() OVERRIDE { |
| 63 aura::test::AuraTestBase::SetUp(); |
| 64 |
| 65 #if defined(OS_CHROMEOS) |
| 66 // Fake a ChromeOS running env. |
| 67 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
| 68 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
| 69 #endif |
| 70 } |
| 71 |
| 72 virtual void TearDown() OVERRIDE { |
| 73 aura::test::AuraTestBase::TearDown(); |
| 74 |
| 75 #if defined(OS_CHROMEOS) |
| 76 // Revert the CrOS testing env otherwise the following non-CrOS aura |
| 77 // tests will fail. |
| 78 // Fake a ChromeOS running env. |
| 79 const char* kLsbRelease = ""; |
| 80 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
| 81 #endif |
| 82 } |
| 83 }; |
61 | 84 |
62 // Send X touch events to one WindowTreeHost. The WindowTreeHost's | 85 // Send X touch events to one WindowTreeHost. The WindowTreeHost's |
63 // delegate will get corresponding ui::TouchEvent if the touch events | 86 // delegate will get corresponding ui::TouchEvent if the touch events |
64 // are targeting this WindowTreeHost. | 87 // are targeting this WindowTreeHost. |
65 TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { | 88 TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { |
66 // Fake a ChromeOS running env. | |
67 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | |
68 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
69 | |
70 scoped_ptr<aura::WindowTreeHostX11> window_tree_host( | 89 scoped_ptr<aura::WindowTreeHostX11> window_tree_host( |
71 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 90 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
72 window_tree_host->InitHost(); | 91 window_tree_host->InitHost(); |
73 scoped_ptr<RootWindowEventHandler> handler( | 92 scoped_ptr<RootWindowEventHandler> handler( |
74 new RootWindowEventHandler(window_tree_host.get())); | 93 new RootWindowEventHandler(window_tree_host.get())); |
75 | 94 |
76 std::vector<unsigned int> devices; | 95 std::vector<unsigned int> devices; |
77 devices.push_back(0); | 96 devices.push_back(0); |
78 ui::SetUpTouchDevicesForTest(devices); | 97 ui::SetUpTouchDevicesForTest(devices); |
79 std::vector<ui::Valuator> valuators; | 98 std::vector<ui::Valuator> valuators; |
(...skipping 30 matching lines...) Expand all Loading... |
110 | 129 |
111 scoped_xevent.InitTouchEvent( | 130 scoped_xevent.InitTouchEvent( |
112 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); | 131 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); |
113 if (window_tree_host->CanDispatchEvent(scoped_xevent)) | 132 if (window_tree_host->CanDispatchEvent(scoped_xevent)) |
114 window_tree_host->DispatchEvent(scoped_xevent); | 133 window_tree_host->DispatchEvent(scoped_xevent); |
115 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); | 134 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); |
116 EXPECT_EQ(0, handler->last_touch_id()); | 135 EXPECT_EQ(0, handler->last_touch_id()); |
117 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); | 136 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); |
118 | 137 |
119 handler.reset(); | 138 handler.reset(); |
120 | |
121 // Revert the CrOS testing env otherwise the following non-CrOS aura | |
122 // tests will fail. | |
123 // Fake a ChromeOS running env. | |
124 kLsbRelease = ""; | |
125 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
126 } | 139 } |
127 | 140 |
128 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is | 141 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is |
129 // the event target of the X touch events should generate the corresponding | 142 // the event target of the X touch events should generate the corresponding |
130 // ui::TouchEvent for its delegate. | 143 // ui::TouchEvent for its delegate. |
131 TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { | 144 TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { |
132 // Fake a ChromeOS running env. | |
133 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | |
134 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
135 | |
136 scoped_ptr<aura::WindowTreeHostX11> window_tree_host1( | 145 scoped_ptr<aura::WindowTreeHostX11> window_tree_host1( |
137 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 146 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
138 window_tree_host1->InitHost(); | 147 window_tree_host1->InitHost(); |
139 scoped_ptr<RootWindowEventHandler> handler1( | 148 scoped_ptr<RootWindowEventHandler> handler1( |
140 new RootWindowEventHandler(window_tree_host1.get())); | 149 new RootWindowEventHandler(window_tree_host1.get())); |
141 | 150 |
142 int host2_y_offset = 1700; | 151 int host2_y_offset = 1700; |
143 scoped_ptr<aura::WindowTreeHostX11> window_tree_host2( | 152 scoped_ptr<aura::WindowTreeHostX11> window_tree_host2( |
144 new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); | 153 new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); |
145 window_tree_host2->InitHost(); | 154 window_tree_host2->InitHost(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 window_tree_host2->DispatchEvent(scoped_xevent); | 240 window_tree_host2->DispatchEvent(scoped_xevent); |
232 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 241 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
233 EXPECT_EQ(-1, handler1->last_touch_id()); | 242 EXPECT_EQ(-1, handler1->last_touch_id()); |
234 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 243 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
235 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); | 244 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
236 EXPECT_EQ(1, handler2->last_touch_id()); | 245 EXPECT_EQ(1, handler2->last_touch_id()); |
237 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); | 246 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); |
238 | 247 |
239 handler1.reset(); | 248 handler1.reset(); |
240 handler2.reset(); | 249 handler2.reset(); |
241 | |
242 // Revert the CrOS testing env otherwise the following non-CrOS aura | |
243 // tests will fail. | |
244 // Fake a ChromeOS running env. | |
245 kLsbRelease = ""; | |
246 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
247 } | 250 } |
248 | 251 |
249 } // namespace aura | 252 } // namespace aura |
OLD | NEW |