OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 model_->Add(item); | 213 model_->Add(item); |
214 return id; | 214 return id; |
215 } | 215 } |
216 | 216 |
217 LauncherID AddTabbedBrowser() { | 217 LauncherID AddTabbedBrowser() { |
218 LauncherID id = AddTabbedBrowserNoWait(); | 218 LauncherID id = AddTabbedBrowserNoWait(); |
219 test_api_->RunMessageLoopUntilAnimationsDone(); | 219 test_api_->RunMessageLoopUntilAnimationsDone(); |
220 return id; | 220 return id; |
221 } | 221 } |
222 | 222 |
223 LauncherID AddPanel() { | |
224 LauncherID id = AddPanelNoWait(); | |
225 test_api_->RunMessageLoopUntilAnimationsDone(); | |
226 return id; | |
227 } | |
228 | |
223 LauncherID AddPlatformAppNoWait() { | 229 LauncherID AddPlatformAppNoWait() { |
224 LauncherItem item; | 230 LauncherItem item; |
225 item.type = TYPE_PLATFORM_APP; | 231 item.type = TYPE_PLATFORM_APP; |
226 item.status = STATUS_RUNNING; | 232 item.status = STATUS_RUNNING; |
227 | 233 |
228 LauncherID id = model_->next_id(); | 234 LauncherID id = model_->next_id(); |
229 model_->Add(item); | 235 model_->Add(item); |
230 return id; | 236 return id; |
231 } | 237 } |
232 | 238 |
239 LauncherID AddPanelNoWait() { | |
240 LauncherItem item; | |
241 item.type = TYPE_APP_PANEL; | |
242 item.status = STATUS_RUNNING; | |
243 | |
244 LauncherID id = model_->next_id(); | |
245 model_->Add(item); | |
246 return id; | |
247 } | |
248 | |
233 LauncherID AddPlatformApp() { | 249 LauncherID AddPlatformApp() { |
234 LauncherID id = AddPlatformAppNoWait(); | 250 LauncherID id = AddPlatformAppNoWait(); |
235 test_api_->RunMessageLoopUntilAnimationsDone(); | 251 test_api_->RunMessageLoopUntilAnimationsDone(); |
236 return id; | 252 return id; |
237 } | 253 } |
238 | 254 |
239 void RemoveByID(LauncherID id) { | 255 void RemoveByID(LauncherID id) { |
240 model_->RemoveItemAt(model_->ItemIndexByID(id)); | 256 model_->RemoveItemAt(model_->ItemIndexByID(id)); |
241 test_api_->RunMessageLoopUntilAnimationsDone(); | 257 test_api_->RunMessageLoopUntilAnimationsDone(); |
242 } | 258 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 | 379 |
364 last_added = AddAppShortcut(); | 380 last_added = AddAppShortcut(); |
365 } | 381 } |
366 | 382 |
367 // The last added app short button should be visible. | 383 // The last added app short button should be visible. |
368 EXPECT_TRUE(GetButtonByID(last_added)->visible()); | 384 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
369 // And the browser button is invisible. | 385 // And the browser button is invisible. |
370 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); | 386 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); |
371 } | 387 } |
372 | 388 |
389 TEST_F(LauncherViewTest, AddPanelHidesTabbedBrowser) { | |
390 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | |
391 test_api_->GetButtonCount()); | |
392 | |
393 // Add tabbed browser until overflow, remember last visible tabbed browser. | |
394 LauncherID first_added = AddTabbedBrowser(); | |
395 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | |
396 LauncherID last_visible = first_added; | |
397 while (true) { | |
398 LauncherID added = AddTabbedBrowser(); | |
399 if (test_api_->IsOverflowButtonVisible()) { | |
400 EXPECT_FALSE(GetButtonByID(added)->visible()); | |
401 break; | |
402 } | |
403 last_visible = added; | |
stevenjb
2012/11/26 18:19:21
We should add something like:
++items_added;
ASSER
flackr
2012/11/27 18:40:21
Done. And the other instances of this in the file.
| |
404 } | |
405 | |
406 LauncherID panel = AddPanel(); | |
407 EXPECT_TRUE(GetButtonByID(panel)->visible()); | |
408 EXPECT_FALSE(GetButtonByID(last_visible)->visible()); | |
409 | |
410 RemoveByID(panel); | |
411 EXPECT_TRUE(GetButtonByID(last_visible)->visible()); | |
412 } | |
413 | |
414 TEST_F(LauncherViewTest, PanelsHideLast) { | |
415 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | |
416 test_api_->GetButtonCount()); | |
417 | |
418 // Add tabbed browser. | |
419 LauncherID browser = AddTabbedBrowser(); | |
420 LauncherID first_panel = AddPanel(); | |
421 | |
422 EXPECT_TRUE(GetButtonByID(browser)->visible()); | |
423 EXPECT_TRUE(GetButtonByID(first_panel)->visible()); | |
424 | |
425 LauncherID last_panel = first_panel; | |
426 while (!test_api_->IsOverflowButtonVisible()) | |
427 last_panel = AddPanel(); | |
stevenjb
2012/11/26 18:19:21
Same here.
flackr
2012/11/27 18:40:21
Done.
| |
428 | |
429 EXPECT_TRUE(GetButtonByID(last_panel)->visible()); | |
430 EXPECT_TRUE(GetButtonByID(first_panel)->visible()); | |
431 EXPECT_FALSE(GetButtonByID(browser)->visible()); | |
432 } | |
433 | |
373 // Adds button until overflow then removes first added one. Verifies that | 434 // Adds button until overflow then removes first added one. Verifies that |
374 // the last added one changes from invisible to visible and overflow | 435 // the last added one changes from invisible to visible and overflow |
375 // chevron is gone. | 436 // chevron is gone. |
376 TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) { | 437 TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) { |
377 // All buttons should be visible. | 438 // All buttons should be visible. |
378 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 439 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
379 test_api_->GetButtonCount()); | 440 test_api_->GetButtonCount()); |
380 | 441 |
381 // Add tabbed browser until overflow. | 442 // Add tabbed browser until overflow. |
382 LauncherID first_added= AddTabbedBrowser(); | 443 LauncherID first_added = AddTabbedBrowser(); |
383 LauncherID last_added = first_added; | 444 LauncherID last_added = first_added; |
384 while (!test_api_->IsOverflowButtonVisible()) | 445 while (!test_api_->IsOverflowButtonVisible()) |
385 last_added = AddTabbedBrowser(); | 446 last_added = AddTabbedBrowser(); |
386 | 447 |
387 // Expect add more than 1 button. First added is visible and last is not. | 448 // Expect add more than 1 button. First added is visible and last is not. |
388 EXPECT_NE(first_added, last_added); | 449 EXPECT_NE(first_added, last_added); |
389 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | 450 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
390 EXPECT_FALSE(GetButtonByID(last_added)->visible()); | 451 EXPECT_FALSE(GetButtonByID(last_added)->visible()); |
391 | 452 |
392 // Remove first added. | 453 // Remove first added. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 const int app_list_button_index = test_api_->GetButtonCount() - 1; | 782 const int app_list_button_index = test_api_->GetButtonCount() - 1; |
722 const gfx::Rect& app_list_ideal_bounds = | 783 const gfx::Rect& app_list_ideal_bounds = |
723 test_api_->GetIdealBoundsByIndex(app_list_button_index); | 784 test_api_->GetIdealBoundsByIndex(app_list_button_index); |
724 const gfx::Rect& app_list_bounds = | 785 const gfx::Rect& app_list_bounds = |
725 test_api_->GetBoundsByIndex(app_list_button_index); | 786 test_api_->GetBoundsByIndex(app_list_button_index); |
726 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); | 787 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); |
727 } | 788 } |
728 | 789 |
729 } // namespace test | 790 } // namespace test |
730 } // namespace ash | 791 } // namespace ash |
OLD | NEW |