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

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

Issue 12674045: ShellWindowLauncherItemController::RestoreOrShow -> ShowAndActivate (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
« no previous file with comments | « no previous file | chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.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 (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 10 matching lines...) Expand all
21 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 21 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
22 #include "chrome/browser/extensions/shell_window_registry.h" 22 #include "chrome/browser/extensions/shell_window_registry.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" 24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h"
25 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 25 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
26 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_commands.h" 27 #include "chrome/browser/ui/browser_commands.h"
28 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
30 #include "chrome/browser/ui/extensions/application_launch.h" 30 #include "chrome/browser/ui/extensions/application_launch.h"
31 #include "chrome/browser/ui/extensions/native_app_window.h"
31 #include "chrome/browser/ui/extensions/shell_window.h" 32 #include "chrome/browser/ui/extensions/shell_window.h"
32 #include "chrome/browser/ui/host_desktop.h" 33 #include "chrome/browser/ui/host_desktop.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 34 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/extensions/extension_constants.h" 37 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
38 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_source.h" 40 #include "content/public/browser/notification_source.h"
40 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
41 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
42 #include "ui/aura/window.h" 43 #include "ui/aura/window.h"
44 #include "ui/base/events/event.h"
43 45
44 using extensions::Extension; 46 using extensions::Extension;
45 using content::WebContents; 47 using content::WebContents;
46 48
47 namespace { 49 namespace {
48 50
51 class TestEvent : public ui::Event {
52 public:
53 explicit TestEvent(ui::EventType type)
54 : ui::Event(type, base::TimeDelta(), 0) {
55 }
56 virtual ~TestEvent() {
57 }
58
59 private:
60 DISALLOW_COPY_AND_ASSIGN(TestEvent);
61 };
62
49 class TestShellWindowRegistryObserver 63 class TestShellWindowRegistryObserver
50 : public extensions::ShellWindowRegistry::Observer { 64 : public extensions::ShellWindowRegistry::Observer {
51 public: 65 public:
52 explicit TestShellWindowRegistryObserver(Profile* profile) 66 explicit TestShellWindowRegistryObserver(Profile* profile)
53 : profile_(profile), 67 : profile_(profile),
54 icon_updates_(0) { 68 icon_updates_(0) {
55 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this); 69 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this);
56 } 70 }
57 71
58 virtual ~TestShellWindowRegistryObserver() { 72 virtual ~TestShellWindowRegistryObserver() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // the app list, and the item at [count - 2] will be the desired item. 126 // the app list, and the item at [count - 2] will be the desired item.
113 return launcher_model()->items()[launcher_model()->item_count() - 2]; 127 return launcher_model()->items()[launcher_model()->item_count() - 2];
114 } 128 }
115 129
116 const ash::LauncherItem& GetLastLauncherPanelItem() { 130 const ash::LauncherItem& GetLastLauncherPanelItem() {
117 // Panels show up on the right side of the launcher, so the desired item 131 // Panels show up on the right side of the launcher, so the desired item
118 // will be the last one. 132 // will be the last one.
119 return launcher_model()->items()[launcher_model()->item_count() - 1]; 133 return launcher_model()->items()[launcher_model()->item_count() - 1];
120 } 134 }
121 135
122 const LauncherItemController* GetItemController(ash::LauncherID id) { 136 LauncherItemController* GetItemController(ash::LauncherID id) {
123 return controller_->id_to_item_controller_map_[id]; 137 return controller_->id_to_item_controller_map_[id];
124 } 138 }
125 139
126 // Returns the number of menu items, ignoring separators. 140 // Returns the number of menu items, ignoring separators.
127 int GetNumApplicationMenuItems(const ash::LauncherItem& item) { 141 int GetNumApplicationMenuItems(const ash::LauncherItem& item) {
128 const int event_flags = 0; 142 const int event_flags = 0;
129 scoped_ptr<ash::LauncherMenuModel> menu( 143 scoped_ptr<ash::LauncherMenuModel> menu(
130 controller_->CreateApplicationMenu(item, event_flags)); 144 controller_->CreateApplicationMenu(item, event_flags));
131 int num_items = 0; 145 int num_items = 0;
132 for (int i = 0; i < menu->GetItemCount(); ++i) { 146 for (int i = 0; i < menu->GetItemCount(); ++i) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // First app should be active again. 544 // First app should be active again.
531 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status); 545 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status);
532 546
533 // Close first app. 547 // Close first app.
534 CloseShellWindow(window1b); 548 CloseShellWindow(window1b);
535 CloseShellWindow(window1); 549 CloseShellWindow(window1);
536 --item_count; 550 --item_count;
537 EXPECT_EQ(item_count, launcher_model()->item_count()); 551 EXPECT_EQ(item_count, launcher_model()->item_count());
538 } 552 }
539 553
554 // Confirm that Click behavior for app windows is correnct.
555 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, AppClickBehavior) {
556 // Launch a platform app and create a window for it.
557 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
558 ShellWindow* window1 = CreateShellWindow(extension1);
559 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
560 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
561 // Confirm that a controller item was created and is the correct state.
562 const ash::LauncherItem& item1 = GetLastLauncherItem();
563 LauncherItemController* item1_controller = GetItemController(item1.id);
564 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
565 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
566 // Minimize the window and confirm that the controller item is updated.
567 window1->GetBaseWindow()->Minimize();
568 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible());
569 EXPECT_FALSE(window1->GetBaseWindow()->IsActive());
570 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
571 // Clicking on the controller should activate the window.
572 TestEvent default_event(ui::ET_MOUSE_PRESSED);
573 item1_controller->Clicked(default_event);
574 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
575 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
576 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
577 // Maximizing a window should preserve state after minimize + click.
578 window1->GetBaseWindow()->Maximize();
579 window1->GetBaseWindow()->Minimize();
580 item1_controller->Clicked(default_event);
581 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
582 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
583 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
584 }
585
540 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, 586 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest,
541 BrowserActivation) { 587 BrowserActivation) {
542 int item_count = launcher_model()->item_count(); 588 int item_count = launcher_model()->item_count();
543 589
544 // First run app. 590 // First run app.
545 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 591 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
546 CreateShellWindow(extension1); 592 CreateShellWindow(extension1);
547 ++item_count; 593 ++item_count;
548 ASSERT_EQ(item_count, launcher_model()->item_count()); 594 ASSERT_EQ(item_count, launcher_model()->item_count());
549 const ash::LauncherItem& item1 = GetLastLauncherItem(); 595 const ash::LauncherItem& item1 = GetLastLauncherItem();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 1045 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
1000 1046
1001 // Create only a tab. 1047 // Create only a tab.
1002 LoadAndLaunchExtension("app1", 1048 LoadAndLaunchExtension("app1",
1003 extension_misc::LAUNCH_TAB, 1049 extension_misc::LAUNCH_TAB,
1004 NEW_FOREGROUND_TAB); 1050 NEW_FOREGROUND_TAB);
1005 1051
1006 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); 1052 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false));
1007 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 1053 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
1008 } 1054 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698