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

Side by Side Diff: athena/wm/window_manager_unittest.cc

Issue 480293003: Adding functions to the window_list_provider for accessing the activities window list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the other functions as well Created 6 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 | Annotate | Revision Log
OLDNEW
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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/screen/public/screen_manager.h" 7 #include "athena/screen/public/screen_manager.h"
8 #include "athena/test/athena_test_base.h" 8 #include "athena/test/athena_test_base.h"
9 #include "athena/wm/public/window_list_provider.h" 9 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/split_view_controller.h" 10 #include "athena/wm/split_view_controller.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 test::WindowManagerImplTestApi wm_api; 145 test::WindowManagerImplTestApi wm_api;
146 aura::client::ParentWindowWithContext( 146 aura::client::ParentWindowWithContext(
147 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 147 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
148 aura::client::ParentWindowWithContext( 148 aura::client::ParentWindowWithContext(
149 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 149 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
150 aura::client::ParentWindowWithContext( 150 aura::client::ParentWindowWithContext(
151 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 151 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
152 152
153 EXPECT_EQ(third.get(), 153 EXPECT_EQ(third.get(),
154 wm_api.GetWindowListProvider()->GetWindowList().back()); 154 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
155 155
156 // Do a two-finger swipe from the left bezel. 156 // Do a two-finger swipe from the left bezel.
157 ui::test::EventGenerator generator(root_window()); 157 ui::test::EventGenerator generator(root_window());
158 const gfx::Point left_bezel_points[2] = { 158 const gfx::Point left_bezel_points[2] = {
159 gfx::Point(2, 10), gfx::Point(4, 20), 159 gfx::Point(2, 10), gfx::Point(4, 20),
160 }; 160 };
161 const int kEventTimeSepration = 16; 161 const int kEventTimeSepration = 16;
162 int width = root_window()->bounds().width(); 162 int width = root_window()->bounds().width();
163 generator.GestureMultiFingerScroll( 163 generator.GestureMultiFingerScroll(
164 2, left_bezel_points, kEventTimeSepration, 1, width, 0); 164 2, left_bezel_points, kEventTimeSepration, 1, width, 0);
165 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 165 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
166 EXPECT_EQ(second.get(), 166 EXPECT_EQ(second.get(),
167 wm_api.GetWindowListProvider()->GetWindowList().back()); 167 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
168 EXPECT_FALSE(first->IsVisible());
169 EXPECT_TRUE(second->IsVisible());
170 EXPECT_FALSE(third->IsVisible());
171 } 168 }
172 169
173 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { 170 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
174 aura::test::TestWindowDelegate delegate; 171 aura::test::TestWindowDelegate delegate;
175 delegate.set_window_component(HTCAPTION); 172 delegate.set_window_component(HTCAPTION);
176 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 173 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
177 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 174 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
178 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 175 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
179 176
180 test::WindowManagerImplTestApi wm_api; 177 test::WindowManagerImplTestApi wm_api;
181 aura::client::ParentWindowWithContext( 178 aura::client::ParentWindowWithContext(
182 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 179 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
183 aura::client::ParentWindowWithContext( 180 aura::client::ParentWindowWithContext(
184 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 181 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
185 aura::client::ParentWindowWithContext( 182 aura::client::ParentWindowWithContext(
186 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 183 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
187 184
188 EXPECT_EQ(third.get(), 185 EXPECT_EQ(third.get(),
189 wm_api.GetWindowListProvider()->GetWindowList().back()); 186 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
190 187
191 // Do a title-swipe from the top to switch to the previous window. 188 // Do a title-swipe from the top to switch to the previous window.
192 ui::test::EventGenerator generator(root_window()); 189 ui::test::EventGenerator generator(root_window());
193 generator.GestureScrollSequence(gfx::Point(20, 10), 190 generator.GestureScrollSequence(gfx::Point(20, 10),
194 gfx::Point(20, 400), 191 gfx::Point(20, 400),
195 base::TimeDelta::FromMilliseconds(20), 192 base::TimeDelta::FromMilliseconds(20),
196 5); 193 5);
197 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 194 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
198 EXPECT_EQ(second.get(), 195 EXPECT_EQ(second.get(),
199 wm_api.GetWindowListProvider()->GetWindowList().back()); 196 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
200 EXPECT_TRUE(second->IsVisible()); 197 EXPECT_TRUE(second->IsVisible());
201 EXPECT_FALSE(third->IsVisible()); 198 EXPECT_FALSE(third->IsVisible());
202 199
203 // Performing the same gesture again will switch back to |third|. 200 // Performing the same gesture again will switch back to |third|.
204 generator.GestureScrollSequence(gfx::Point(20, 10), 201 generator.GestureScrollSequence(gfx::Point(20, 10),
205 gfx::Point(20, 400), 202 gfx::Point(20, 400),
206 base::TimeDelta::FromMilliseconds(20), 203 base::TimeDelta::FromMilliseconds(20),
207 5); 204 5);
208 EXPECT_TRUE(wm::IsActiveWindow(third.get())); 205 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
209 EXPECT_EQ(third.get(), 206 EXPECT_EQ(third.get(),
210 wm_api.GetWindowListProvider()->GetWindowList().back()); 207 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
211 EXPECT_FALSE(second->IsVisible()); 208 EXPECT_FALSE(second->IsVisible());
212 EXPECT_TRUE(third->IsVisible()); 209 EXPECT_TRUE(third->IsVisible());
213 210
214 // Perform a swipe that doesn't go enough to perform the window switch. 211 // Perform a swipe that doesn't go enough to perform the window switch.
215 generator.GestureScrollSequence(gfx::Point(20, 10), 212 generator.GestureScrollSequence(gfx::Point(20, 10),
216 gfx::Point(20, 90), 213 gfx::Point(20, 90),
217 base::TimeDelta::FromMilliseconds(20), 214 base::TimeDelta::FromMilliseconds(20),
218 5); 215 5);
219 EXPECT_TRUE(wm::IsActiveWindow(third.get())); 216 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
220 EXPECT_EQ(third.get(), 217 EXPECT_EQ(third.get(),
221 wm_api.GetWindowListProvider()->GetWindowList().back()); 218 wm_api.GetWindowListProvider()->GetCurrentWindowList().back());
222 EXPECT_FALSE(second->IsVisible()); 219 EXPECT_FALSE(second->IsVisible());
223 EXPECT_TRUE(third->IsVisible()); 220 EXPECT_TRUE(third->IsVisible());
224 } 221 }
225 222
226 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { 223 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) {
227 aura::test::TestWindowDelegate delegate; 224 aura::test::TestWindowDelegate delegate;
228 delegate.set_window_component(HTCAPTION); 225 delegate.set_window_component(HTCAPTION);
229 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 226 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
230 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 227 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
231 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 228 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
(...skipping 24 matching lines...) Expand all
256 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); 253 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window());
257 254
258 // Swipe the title of the left window. It should switch to |second|. 255 // Swipe the title of the left window. It should switch to |second|.
259 generator.GestureScrollSequence(gfx::Point(20, 10), 256 generator.GestureScrollSequence(gfx::Point(20, 10),
260 gfx::Point(20, 400), 257 gfx::Point(20, 400),
261 base::TimeDelta::FromMilliseconds(20), 258 base::TimeDelta::FromMilliseconds(20),
262 5); 259 5);
263 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); 260 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
264 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); 261 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window());
265 aura::Window::Windows windows = 262 aura::Window::Windows windows =
266 wm_api.GetWindowListProvider()->GetWindowList(); 263 wm_api.GetWindowListProvider()->GetCurrentWindowList();
267 ASSERT_EQ(4u, windows.size()); 264 ASSERT_EQ(4u, windows.size());
268 EXPECT_EQ(second.get(), windows[3]); 265 EXPECT_EQ(second.get(), windows[3]);
269 EXPECT_EQ(third.get(), windows[2]); 266 EXPECT_EQ(third.get(), windows[2]);
270 EXPECT_EQ(fourth.get(), windows[1]); 267 EXPECT_EQ(fourth.get(), windows[1]);
271 268
272 // Swipe the title of the right window now. It should switch to |third|. 269 // Swipe the title of the right window now. It should switch to |third|.
273 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), 270 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10),
274 gfx::Point(x_middle + 20, 400), 271 gfx::Point(x_middle + 20, 400),
275 base::TimeDelta::FromMilliseconds(20), 272 base::TimeDelta::FromMilliseconds(20),
276 5); 273 5);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 363 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
367 overview_delegate->OnSelectWindow(w1.get()); 364 overview_delegate->OnSelectWindow(w1.get());
368 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 365 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
369 EXPECT_TRUE(w1->IsVisible()); 366 EXPECT_TRUE(w1->IsVisible());
370 // Make sure the windows that were in split-view mode are hidden. 367 // Make sure the windows that were in split-view mode are hidden.
371 EXPECT_FALSE(w2->IsVisible()); 368 EXPECT_FALSE(w2->IsVisible());
372 EXPECT_FALSE(w3->IsVisible()); 369 EXPECT_FALSE(w3->IsVisible());
373 } 370 }
374 371
375 } // namespace athena 372 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698