OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1626 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1627 int tab_count1 = tab_strip->count(); | 1627 int tab_count1 = tab_strip->count(); |
1628 TabStripModel* tab_strip2 = browser2->tab_strip_model(); | 1628 TabStripModel* tab_strip2 = browser2->tab_strip_model(); |
1629 int tab_count2 = tab_strip2->count(); | 1629 int tab_count2 = tab_strip2->count(); |
1630 | 1630 |
1631 // Check that we have two browsers and the inactive browser remained inactive. | 1631 // Check that we have two browsers and the inactive browser remained inactive. |
1632 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1632 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1633 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), | 1633 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), |
1634 browser()); | 1634 browser()); |
1635 // Check that the LRU browser list does only contain the original browser. | 1635 // Check that the LRU browser list does only contain the original browser. |
1636 BrowserList* ash_browser_list = | 1636 BrowserList* browser_list = BrowserList::GetInstance(); |
1637 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 1637 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); |
1638 BrowserList::const_reverse_iterator it = | |
1639 ash_browser_list->begin_last_active(); | |
1640 EXPECT_EQ(*it, browser()); | 1638 EXPECT_EQ(*it, browser()); |
1641 ++it; | 1639 ++it; |
1642 EXPECT_EQ(it, ash_browser_list->end_last_active()); | 1640 EXPECT_EQ(it, browser_list->end_last_active()); |
1643 | 1641 |
1644 // Now request to either activate an existing app or create a new one. | 1642 // Now request to either activate an existing app or create a new one. |
1645 LauncherItemController* item_controller = | 1643 LauncherItemController* item_controller = |
1646 controller_->GetLauncherItemController(shortcut_id); | 1644 controller_->GetLauncherItemController(shortcut_id); |
1647 item_controller->ItemSelected(ui::KeyEvent(ui::ET_KEY_RELEASED, | 1645 item_controller->ItemSelected(ui::KeyEvent(ui::ET_KEY_RELEASED, |
1648 ui::VKEY_RETURN, | 1646 ui::VKEY_RETURN, |
1649 ui::EF_NONE)); | 1647 ui::EF_NONE)); |
1650 | 1648 |
1651 // Check that we have set focus on the existing application and nothing new | 1649 // Check that we have set focus on the existing application and nothing new |
1652 // was created. | 1650 // was created. |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 // Create a windowed application. | 2141 // Create a windowed application. |
2144 AppLaunchParams params( | 2142 AppLaunchParams params( |
2145 profile(), controller_->GetExtensionForAppID(extensions::kWebStoreAppId), | 2143 profile(), controller_->GetExtensionForAppID(extensions::kWebStoreAppId), |
2146 CURRENT_TAB, chrome::HOST_DESKTOP_TYPE_ASH, extensions::SOURCE_TEST); | 2144 CURRENT_TAB, chrome::HOST_DESKTOP_TYPE_ASH, extensions::SOURCE_TEST); |
2147 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 2145 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
2148 OpenApplication(params); | 2146 OpenApplication(params); |
2149 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); | 2147 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); |
2150 | 2148 |
2151 // Find the browser which holds our app. | 2149 // Find the browser which holds our app. |
2152 Browser* app_browser = NULL; | 2150 Browser* app_browser = NULL; |
2153 const BrowserList* ash_browser_list = | 2151 const BrowserList* browser_list = BrowserList::GetInstance(); |
2154 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | |
2155 for (BrowserList::const_reverse_iterator it = | 2152 for (BrowserList::const_reverse_iterator it = |
2156 ash_browser_list->begin_last_active(); | 2153 browser_list->begin_last_active(); |
2157 it != ash_browser_list->end_last_active() && !app_browser; ++it) { | 2154 it != browser_list->end_last_active() && !app_browser; ++it) { |
2158 if ((*it)->is_app()) { | 2155 if ((*it)->is_app()) { |
2159 app_browser = *it; | 2156 app_browser = *it; |
2160 break; | 2157 break; |
2161 } | 2158 } |
2162 } | 2159 } |
2163 ASSERT_TRUE(app_browser); | 2160 ASSERT_TRUE(app_browser); |
2164 | 2161 |
2165 // After navigating away in the app, we should still be active. | 2162 // After navigating away in the app, we should still be active. |
2166 ui_test_utils::NavigateToURL(app_browser, | 2163 ui_test_utils::NavigateToURL(app_browser, |
2167 GURL("http://www.foo.com/bar.html")); | 2164 GURL("http://www.foo.com/bar.html")); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2289 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2293 | 2290 |
2294 // There should be two new browsers. | 2291 // There should be two new browsers. |
2295 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); | 2292 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); |
2296 | 2293 |
2297 // The apps should now be running, with the last opened app active. | 2294 // The apps should now be running, with the last opened app active. |
2298 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2295 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2299 EXPECT_EQ(ash::STATUS_ACTIVE, | 2296 EXPECT_EQ(ash::STATUS_ACTIVE, |
2300 model_->ItemByID(bookmark_app_shelf_id)->status); | 2297 model_->ItemByID(bookmark_app_shelf_id)->status); |
2301 } | 2298 } |
OLD | NEW |