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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc

Issue 13007002: Create launcher app list for shell windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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 (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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/launcher/launcher_util.h" 9 #include "ash/launcher/launcher_util.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const ash::LauncherItem& GetLastLauncherPanelItem() { 116 const ash::LauncherItem& GetLastLauncherPanelItem() {
117 // Panels show up on the right side of the launcher, so the desired item 117 // Panels show up on the right side of the launcher, so the desired item
118 // will be the last one. 118 // will be the last one.
119 return launcher_model()->items()[launcher_model()->item_count() - 1]; 119 return launcher_model()->items()[launcher_model()->item_count() - 1];
120 } 120 }
121 121
122 const LauncherItemController* GetItemController(ash::LauncherID id) { 122 const LauncherItemController* GetItemController(ash::LauncherID id) {
123 return controller_->id_to_item_controller_map_[id]; 123 return controller_->id_to_item_controller_map_[id];
124 } 124 }
125 125
126 // Returns the number of menu items, ignoring separators.
127 int GetNumApplicationMenuItems(const ash::LauncherItem& item) {
128 const int event_flags = 0;
129 scoped_ptr<ash::LauncherMenuModel> menu(
130 controller_->CreateApplicationMenu(item, event_flags));
131 int num_items = 0;
132 for (int i = 0; i < menu->GetItemCount(); ++i) {
133 if (menu->GetTypeAt(i) != ui::MenuModel::TYPE_SEPARATOR)
134 ++num_items;
135 }
136 return num_items;
137 }
138
126 ash::Launcher* launcher_; 139 ash::Launcher* launcher_;
127 ChromeLauncherControllerPerApp* controller_; 140 ChromeLauncherControllerPerApp* controller_;
128 141
129 private: 142 private:
130 143
131 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformPerAppAppBrowserTest); 144 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformPerAppAppBrowserTest);
132 }; 145 };
133 146
134 // TODO(skuhne): Change name back to LauncherAppBrowserTest when the 147 // TODO(skuhne): Change name back to LauncherAppBrowserTest when the
135 // old launcher gets ripped out. 148 // old launcher gets ripped out.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 378
366 // First run app. 379 // First run app.
367 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 380 const Extension* extension = LoadAndLaunchPlatformApp("launch");
368 ShellWindow* window1 = CreateShellWindow(extension); 381 ShellWindow* window1 = CreateShellWindow(extension);
369 ++item_count; 382 ++item_count;
370 ASSERT_EQ(item_count, launcher_model()->item_count()); 383 ASSERT_EQ(item_count, launcher_model()->item_count());
371 const ash::LauncherItem& item = GetLastLauncherItem(); 384 const ash::LauncherItem& item = GetLastLauncherItem();
372 ash::LauncherID item_id = item.id; 385 ash::LauncherID item_id = item.id;
373 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 386 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
374 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 387 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
388 EXPECT_EQ(2, GetNumApplicationMenuItems(item)); // Title + 1 window
375 389
376 // Add second window. 390 // Add second window.
377 ShellWindow* window2 = CreateShellWindow(extension); 391 ShellWindow* window2 = CreateShellWindow(extension);
378 // Confirm item stays. 392 // Confirm item stays.
379 ASSERT_EQ(item_count, launcher_model()->item_count()); 393 ASSERT_EQ(item_count, launcher_model()->item_count());
380 const ash::LauncherItem& item2 = *launcher_model()->ItemByID(item_id); 394 const ash::LauncherItem& item2 = *launcher_model()->ItemByID(item_id);
381 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 395 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
396 EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows
382 397
383 // Close second window. 398 // Close second window.
384 CloseShellWindow(window2); 399 CloseShellWindow(window2);
385 // Confirm item stays. 400 // Confirm item stays.
386 ASSERT_EQ(item_count, launcher_model()->item_count()); 401 ASSERT_EQ(item_count, launcher_model()->item_count());
387 const ash::LauncherItem& item3 = *launcher_model()->ItemByID(item_id); 402 const ash::LauncherItem& item3 = *launcher_model()->ItemByID(item_id);
388 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status); 403 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status);
404 EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window
389 405
390 // Close first window. 406 // Close first window.
391 CloseShellWindow(window1); 407 CloseShellWindow(window1);
392 // Confirm item is removed. 408 // Confirm item is removed.
393 --item_count; 409 --item_count;
394 ASSERT_EQ(item_count, launcher_model()->item_count()); 410 ASSERT_EQ(item_count, launcher_model()->item_count());
395 } 411 }
396 412
397 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, MultipleApps) { 413 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, MultipleApps) {
398 int item_count = launcher_model()->item_count(); 414 int item_count = launcher_model()->item_count();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 497 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
482 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 498 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
483 499
484 // Add window for app1. This will activate it. 500 // Add window for app1. This will activate it.
485 ShellWindow* window1b = CreateShellWindow(extension1); 501 ShellWindow* window1b = CreateShellWindow(extension1);
486 ash::wm::ActivateWindow(window1b->GetNativeWindow()); 502 ash::wm::ActivateWindow(window1b->GetNativeWindow());
487 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 503 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
488 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 504 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
489 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 505 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
490 506
491 // Activate launcher item for app1, this will cycle the active window. 507 // Activate launcher item for app1, this will activate the first app window.
492 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 508 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
509 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
493 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 510 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
511 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
494 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 512 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
495 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
496 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
497 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
498 513
499 // Activate the second app again 514 // Activate the second app again
500 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2)); 515 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2));
501 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 516 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
502 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 517 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
503 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 518 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
504 519
505 // Activate the first app again 520 // Activate the first app again
506 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 521 launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
507 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 522 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
508 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 523 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
509 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 524 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
510 525
511 // Close second app. 526 // Close second app.
512 CloseShellWindow(window2); 527 CloseShellWindow(window2);
513 --item_count; 528 --item_count;
514 EXPECT_EQ(item_count, launcher_model()->item_count()); 529 EXPECT_EQ(item_count, launcher_model()->item_count());
515 // First app should be active again. 530 // First app should be active again.
516 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status); 531 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status);
517 532
518 // Close first app. 533 // Close first app.
519 CloseShellWindow(window1b); 534 CloseShellWindow(window1b);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 999 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
985 1000
986 // Create only a tab. 1001 // Create only a tab.
987 LoadAndLaunchExtension("app1", 1002 LoadAndLaunchExtension("app1",
988 extension_misc::LAUNCH_TAB, 1003 extension_misc::LAUNCH_TAB,
989 NEW_FOREGROUND_TAB); 1004 NEW_FOREGROUND_TAB);
990 1005
991 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); 1006 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false));
992 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 1007 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
993 } 1008 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698