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

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

Issue 23708028: Reduce calling count of UpdateAppState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/native_app_window.h" 7 #include "apps/native_app_window.h"
8 #include "apps/shell_window.h" 8 #include "apps/shell_window.h"
9 #include "apps/shell_window_registry.h" 9 #include "apps/shell_window_registry.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 ui_test_utils::NavigateToURL( 1019 ui_test_utils::NavigateToURL(
1020 browser(), GURL("http://www.example.com/path0/bar.html")); 1020 browser(), GURL("http://www.example.com/path0/bar.html"));
1021 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 1021 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
1022 1022
1023 // Navigate back. 1023 // Navigate back.
1024 ui_test_utils::NavigateToURL( 1024 ui_test_utils::NavigateToURL(
1025 browser(), GURL("http://www.example.com/path1/foo.html")); 1025 browser(), GURL("http://www.example.com/path1/foo.html"));
1026 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); 1026 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
1027 } 1027 }
1028 1028
1029 // Confirm that a tab can be moved between browsers while maintaining the
1030 // correct running state.
1031 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, TabDragAndDrop) {
1032 TabStripModel* tab_strip_model1 = browser()->tab_strip_model();
1033 EXPECT_EQ(1, tab_strip_model1->count());
1034 int browser_index = ash::GetBrowserItemIndex(*model_);
1035 EXPECT_TRUE(browser_index >= 0);
1036 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1037
1038 // Create a shortcut for app1.
1039 ash::LauncherID shortcut_id = CreateShortcut("app1");
1040 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
1041 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
1042
1043 // Activate app1 and check its item status.
1044 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
1045 EXPECT_EQ(2, tab_strip_model1->count());
1046 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status);
1047 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
1048
1049 // Create a new browser with blank tab.
1050 Browser* browser2 = CreateBrowser(profile());
1051 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
1052 TabStripModel* tab_strip_model2 = browser2->tab_strip_model();
1053 EXPECT_EQ(1, tab_strip_model2->count());
1054 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
1055 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status);
1056
1057 // Detach a tab at index 1 (app1) from |tab_strip_model1| and insert it as an
1058 // active tab at index 1 to |tab_strip_model2|.
1059 content::WebContents* detached_tab = tab_strip_model1->DetachWebContentsAt(1);
1060 tab_strip_model2->InsertWebContentsAt(1,
1061 detached_tab,
1062 TabStripModel::ADD_ACTIVE);
1063 EXPECT_EQ(1, tab_strip_model1->count());
1064 EXPECT_EQ(2, tab_strip_model2->count());
1065 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status);
1066 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
1067
1068 tab_strip_model1->CloseAllTabs();
1069 tab_strip_model2->CloseAllTabs();
1070 }
1071
1029 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) { 1072 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) {
1030 TabStripModel* tab_strip = browser()->tab_strip_model(); 1073 TabStripModel* tab_strip = browser()->tab_strip_model();
1031 int tab_count = tab_strip->count(); 1074 int tab_count = tab_strip->count();
1032 ash::LauncherID shortcut_id = CreateShortcut("app1"); 1075 ash::LauncherID shortcut_id = CreateShortcut("app1");
1033 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 1076 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
1034 EXPECT_EQ(++tab_count, tab_strip->count()); 1077 EXPECT_EQ(++tab_count, tab_strip->count());
1035 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 1078 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
1036 WebContents* first_tab = tab_strip->GetActiveWebContents(); 1079 WebContents* first_tab = tab_strip->GetActiveWebContents();
1037 1080
1038 // Create new tab owned by app. 1081 // Create new tab owned by app.
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 // Now show overflow bubble. 1845 // Now show overflow bubble.
1803 test.ShowOverflowBubble(); 1846 test.ShowOverflowBubble();
1804 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); 1847 EXPECT_TRUE(launcher_->IsShowingOverflowBubble());
1805 1848
1806 // Unpin first pinned app and there should be no crash. 1849 // Unpin first pinned app and there should be no crash.
1807 controller_->UnpinAppWithID(std::string("fake_app_0")); 1850 controller_->UnpinAppWithID(std::string("fake_app_0"));
1808 1851
1809 test.RunMessageLoopUntilAnimationsDone(); 1852 test.RunMessageLoopUntilAnimationsDone();
1810 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); 1853 EXPECT_FALSE(launcher_->IsShowingOverflowBubble());
1811 } 1854 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698