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

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

Issue 14328031: Adding a minimize function for clicks on launcher items if only a single item (already active) is a… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added one unit test and addressed comments Created 7 years, 8 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 247 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
248 LauncherPerAppAppBrowserTest::SetUpCommandLine(command_line); 248 LauncherPerAppAppBrowserTest::SetUpCommandLine(command_line);
249 command_line->AppendSwitch(switches::kNoStartupWindow); 249 command_line->AppendSwitch(switches::kNoStartupWindow);
250 } 250 }
251 251
252 private: 252 private:
253 253
254 DISALLOW_COPY_AND_ASSIGN(LauncherPerAppAppBrowserTestNoDefaultBrowser); 254 DISALLOW_COPY_AND_ASSIGN(LauncherPerAppAppBrowserTestNoDefaultBrowser);
255 }; 255 };
256 256
257 // Since the default for minimizing on click might change, I added both classes
258 // to either get the minimize on click or not.
259 class LauncherPerAppAppBrowserNoMinimizeOnClick
260 : public LauncherPlatformPerAppAppBrowserTest {
261 protected:
262 LauncherPerAppAppBrowserNoMinimizeOnClick() {}
263 virtual ~LauncherPerAppAppBrowserNoMinimizeOnClick() {}
264
265 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
266 LauncherPlatformPerAppAppBrowserTest::SetUpCommandLine(command_line);
267 command_line->AppendSwitch(
268 switches::kDisableMinimizeOnSecondLauncherItemClick);
269 }
270
271 private:
272
273 DISALLOW_COPY_AND_ASSIGN(LauncherPerAppAppBrowserNoMinimizeOnClick);
274 };
275
276 typedef LauncherPlatformPerAppAppBrowserTest
277 LauncherPerAppAppBrowserMinimizeOnClick;
278
257 // Test that we can launch a platform app and get a running item. 279 // Test that we can launch a platform app and get a running item.
258 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, LaunchUnpinned) { 280 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, LaunchUnpinned) {
259 int item_count = launcher_model()->item_count(); 281 int item_count = launcher_model()->item_count();
260 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 282 const Extension* extension = LoadAndLaunchPlatformApp("launch");
261 ShellWindow* window = CreateShellWindow(extension); 283 ShellWindow* window = CreateShellWindow(extension);
262 ++item_count; 284 ++item_count;
263 ASSERT_EQ(item_count, launcher_model()->item_count()); 285 ASSERT_EQ(item_count, launcher_model()->item_count());
264 const ash::LauncherItem& item = GetLastLauncherItem(); 286 const ash::LauncherItem& item = GetLastLauncherItem();
265 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 287 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
266 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 288 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status); 567 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status);
546 568
547 // Close first app. 569 // Close first app.
548 CloseShellWindow(window1b); 570 CloseShellWindow(window1b);
549 CloseShellWindow(window1); 571 CloseShellWindow(window1);
550 --item_count; 572 --item_count;
551 EXPECT_EQ(item_count, launcher_model()->item_count()); 573 EXPECT_EQ(item_count, launcher_model()->item_count());
552 } 574 }
553 575
554 // Confirm that Click behavior for app windows is correnct. 576 // Confirm that Click behavior for app windows is correnct.
555 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, AppClickBehavior) { 577 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserNoMinimizeOnClick,
578 AppClickBehavior) {
556 // Launch a platform app and create a window for it. 579 // Launch a platform app and create a window for it.
557 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 580 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
558 ShellWindow* window1 = CreateShellWindow(extension1); 581 ShellWindow* window1 = CreateShellWindow(extension1);
559 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 582 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
560 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 583 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
561 // Confirm that a controller item was created and is the correct state. 584 // Confirm that a controller item was created and is the correct state.
562 const ash::LauncherItem& item1 = GetLastLauncherItem(); 585 const ash::LauncherItem& item1 = GetLastLauncherItem();
563 LauncherItemController* item1_controller = GetItemController(item1.id); 586 LauncherItemController* item1_controller = GetItemController(item1.id);
564 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 587 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
565 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 588 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
(...skipping 15 matching lines...) Expand all
581 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 604 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
582 // Maximizing a window should preserve state after minimize + click. 605 // Maximizing a window should preserve state after minimize + click.
583 window1->GetBaseWindow()->Maximize(); 606 window1->GetBaseWindow()->Maximize();
584 window1->GetBaseWindow()->Minimize(); 607 window1->GetBaseWindow()->Minimize();
585 item1_controller->Clicked(click_event); 608 item1_controller->Clicked(click_event);
586 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 609 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
587 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 610 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
588 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); 611 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
589 } 612 }
590 613
614 // Confirm the minimizing click behavior for apps.
615 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserMinimizeOnClick,
616 PackagedAppClickBehaviorInMinimizeMode) {
617 // Launch one platform app and create a window for it.
618 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
619 ShellWindow* window1 = CreateShellWindow(extension1);
620 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
621 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
622
623 // Confirm that a controller item was created and is the correct state.
624 const ash::LauncherItem& item1 = GetLastLauncherItem();
625 LauncherItemController* item1_controller = GetItemController(item1.id);
626 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
627 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
628 EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type());
629 // Since it is already active, clicking it should minimize.
630 TestEvent click_event(ui::ET_MOUSE_PRESSED);
631 item1_controller->Clicked(click_event);
632 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible());
633 EXPECT_FALSE(window1->GetBaseWindow()->IsActive());
634 EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized());
635 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
636 // Clicking the item again should activate the window again.
637 item1_controller->Clicked(click_event);
638 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
639 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
640 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
641 // Maximizing a window should preserve state after minimize + click.
642 window1->GetBaseWindow()->Maximize();
643 window1->GetBaseWindow()->Minimize();
644 item1_controller->Clicked(click_event);
645 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
646 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
647 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
648 window1->GetBaseWindow()->Restore();
649 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
650 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
651 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized());
652
653 // Creating a second window of the same type should change the behavior so
654 // that a click does not change the activation state.
655 ShellWindow* window1a = CreateShellWindow(extension1);
656 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
657 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive());
658 // The first click does nothing.
659 item1_controller->Clicked(click_event);
660 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
661 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
662 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
663 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
664 // The second neither.
665 item1_controller->Clicked(click_event);
666 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
667 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
668 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
669 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
670 }
671
591 // Confirm that click behavior for app panels is correct. 672 // Confirm that click behavior for app panels is correct.
592 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, 673 IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest,
593 AppPanelClickBehavior) { 674 AppPanelClickBehavior) {
594 // Enable experimental APIs to allow panel creation. 675 // Enable experimental APIs to allow panel creation.
595 CommandLine::ForCurrentProcess()->AppendSwitch( 676 CommandLine::ForCurrentProcess()->AppendSwitch(
596 switches::kEnableExperimentalExtensionApis); 677 switches::kEnableExperimentalExtensionApis);
597 // Launch a platform app and create a panel window for it. 678 // Launch a platform app and create a panel window for it.
598 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 679 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
599 ShellWindow::CreateParams params; 680 ShellWindow::CreateParams params;
600 params.window_type = ShellWindow::WINDOW_TYPE_PANEL; 681 params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 1168 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
1088 1169
1089 // Create only a tab. 1170 // Create only a tab.
1090 LoadAndLaunchExtension("app1", 1171 LoadAndLaunchExtension("app1",
1091 extension_misc::LAUNCH_TAB, 1172 extension_misc::LAUNCH_TAB,
1092 NEW_FOREGROUND_TAB); 1173 NEW_FOREGROUND_TAB);
1093 1174
1094 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); 1175 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false));
1095 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); 1176 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
1096 } 1177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698