| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 #include "ui/events/event_constants.h" | 115 #include "ui/events/event_constants.h" |
| 116 #include "ui/views/widget/widget.h" | 116 #include "ui/views/widget/widget.h" |
| 117 | 117 |
| 118 using base::ASCIIToUTF16; | 118 using base::ASCIIToUTF16; |
| 119 using extensions::Extension; | 119 using extensions::Extension; |
| 120 using extensions::Manifest; | 120 using extensions::Manifest; |
| 121 using extensions::UnloadedExtensionReason; | 121 using extensions::UnloadedExtensionReason; |
| 122 using arc::mojom::OrientationLock; | 122 using arc::mojom::OrientationLock; |
| 123 | 123 |
| 124 namespace { | 124 namespace { |
| 125 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; | 125 constexpr char kOfflineGmailUrl[] = "https://mail.google.com/mail/mu/u"; |
| 126 const char* gmail_url = "https://mail.google.com/mail/u"; | 126 constexpr char kGmailUrl[] = "https://mail.google.com/mail/u"; |
| 127 const char* kGmailLaunchURL = "https://mail.google.com/mail/ca"; | 127 constexpr char kGmailLaunchURL[] = "https://mail.google.com/mail/ca"; |
| 128 |
| 129 constexpr char kAppListId[] = "jlfapfmkapbjlfbpjedlinehodkccjee"; |
| 128 | 130 |
| 129 // An extension prefix. | 131 // An extension prefix. |
| 130 const char kCrxAppPrefix[] = "_crx_"; | 132 constexpr char kCrxAppPrefix[] = "_crx_"; |
| 131 | 133 |
| 132 // Dummy app id is used to put at least one pin record to prevent initializing | 134 // Dummy app id is used to put at least one pin record to prevent initializing |
| 133 // pin model with default apps that can affect some tests. | 135 // pin model with default apps that can affect some tests. |
| 134 const char kDummyAppId[] = "dummyappid_dummyappid_dummyappid"; | 136 constexpr char kDummyAppId[] = "dummyappid_dummyappid_dummyappid"; |
| 135 | 137 |
| 136 // ShelfModelObserver implementation that tracks what messages are invoked. | 138 // ShelfModelObserver implementation that tracks what messages are invoked. |
| 137 class TestShelfModelObserver : public ash::ShelfModelObserver { | 139 class TestShelfModelObserver : public ash::ShelfModelObserver { |
| 138 public: | 140 public: |
| 139 TestShelfModelObserver() {} | 141 TestShelfModelObserver() {} |
| 140 ~TestShelfModelObserver() override {} | 142 ~TestShelfModelObserver() override {} |
| 141 | 143 |
| 142 // Overridden from ash::ShelfModelObserver: | 144 // Overridden from ash::ShelfModelObserver: |
| 143 void ShelfItemAdded(int index) override { | 145 void ShelfItemAdded(int index) override { |
| 144 ++added_; | 146 ++added_; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( | 590 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( |
| 589 Profile* profile) { | 591 Profile* profile) { |
| 590 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); | 592 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); |
| 591 new TestBrowserWindowOwner(browser_window); | 593 new TestBrowserWindowOwner(browser_window); |
| 592 return base::WrapUnique( | 594 return base::WrapUnique( |
| 593 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); | 595 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); |
| 594 } | 596 } |
| 595 | 597 |
| 596 void AddAppListLauncherItem() { | 598 void AddAppListLauncherItem() { |
| 597 ash::ShelfItem app_list; | 599 ash::ShelfItem app_list; |
| 598 app_list.id = ash::ShelfID("AppListId"); | 600 app_list.id = ash::ShelfID(kAppListId); |
| 599 app_list.type = ash::TYPE_APP_LIST; | 601 app_list.type = ash::TYPE_APP_LIST; |
| 600 model_->Add(app_list); | 602 model_->Add(app_list); |
| 601 } | 603 } |
| 602 | 604 |
| 603 // Create a launcher controller instance, owned by the test shell delegate. | 605 // Create a launcher controller instance, owned by the test shell delegate. |
| 604 // Returns a pointer to the uninitialized controller. | 606 // Returns a pointer to the uninitialized controller. |
| 605 ChromeLauncherController* CreateLauncherController() { | 607 ChromeLauncherController* CreateLauncherController() { |
| 606 launcher_controller_ = shell_delegate_->CreateLauncherController(profile()); | 608 launcher_controller_ = shell_delegate_->CreateLauncherController(profile()); |
| 607 return launcher_controller_; | 609 return launcher_controller_; |
| 608 } | 610 } |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 // shelf. | 2309 // shelf. |
| 2308 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2310 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 2309 V1AppUpdateOnUserSwitch) { | 2311 V1AppUpdateOnUserSwitch) { |
| 2310 // Create a browser item in the LauncherController. | 2312 // Create a browser item in the LauncherController. |
| 2311 InitLauncherController(); | 2313 InitLauncherController(); |
| 2312 | 2314 |
| 2313 EXPECT_EQ(2, model_->item_count()); | 2315 EXPECT_EQ(2, model_->item_count()); |
| 2314 { | 2316 { |
| 2315 // Create a "windowed gmail app". | 2317 // Create a "windowed gmail app". |
| 2316 std::unique_ptr<V1App> v1_app( | 2318 std::unique_ptr<V1App> v1_app( |
| 2317 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); | 2319 CreateRunningV1App(profile(), extension_misc::kGmailAppId, kGmailUrl)); |
| 2318 EXPECT_EQ(3, model_->item_count()); | 2320 EXPECT_EQ(3, model_->item_count()); |
| 2319 | 2321 |
| 2320 // After switching to a second user the item should be gone. | 2322 // After switching to a second user the item should be gone. |
| 2321 std::string user2 = "user2"; | 2323 std::string user2 = "user2"; |
| 2322 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2324 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2323 const AccountId account_id2( | 2325 const AccountId account_id2( |
| 2324 multi_user_util::GetAccountIdFromProfile(profile2)); | 2326 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2325 const AccountId account_id( | 2327 const AccountId account_id( |
| 2326 multi_user_util::GetAccountIdFromProfile(profile())); | 2328 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2327 SwitchActiveUser(account_id2); | 2329 SwitchActiveUser(account_id2); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2344 // First test: Create an app when the user is not active. | 2346 // First test: Create an app when the user is not active. |
| 2345 std::string user2 = "user2"; | 2347 std::string user2 = "user2"; |
| 2346 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2348 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2347 const AccountId account_id2( | 2349 const AccountId account_id2( |
| 2348 multi_user_util::GetAccountIdFromProfile(profile2)); | 2350 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2349 const AccountId account_id( | 2351 const AccountId account_id( |
| 2350 multi_user_util::GetAccountIdFromProfile(profile())); | 2352 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2351 { | 2353 { |
| 2352 // Create a "windowed gmail app". | 2354 // Create a "windowed gmail app". |
| 2353 std::unique_ptr<V1App> v1_app( | 2355 std::unique_ptr<V1App> v1_app( |
| 2354 CreateRunningV1App(profile2, extension_misc::kGmailAppId, gmail_url)); | 2356 CreateRunningV1App(profile2, extension_misc::kGmailAppId, kGmailUrl)); |
| 2355 EXPECT_EQ(2, model_->item_count()); | 2357 EXPECT_EQ(2, model_->item_count()); |
| 2356 | 2358 |
| 2357 // However - switching to the user should show it. | 2359 // However - switching to the user should show it. |
| 2358 SwitchActiveUser(account_id2); | 2360 SwitchActiveUser(account_id2); |
| 2359 EXPECT_EQ(3, model_->item_count()); | 2361 EXPECT_EQ(3, model_->item_count()); |
| 2360 | 2362 |
| 2361 // Second test: Remove the app when the user is not active and see that it | 2363 // Second test: Remove the app when the user is not active and see that it |
| 2362 // works. | 2364 // works. |
| 2363 SwitchActiveUser(account_id); | 2365 SwitchActiveUser(account_id); |
| 2364 EXPECT_EQ(2, model_->item_count()); | 2366 EXPECT_EQ(2, model_->item_count()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 std::string user2 = "user2"; | 2427 std::string user2 = "user2"; |
| 2426 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2428 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2427 const AccountId account_id( | 2429 const AccountId account_id( |
| 2428 multi_user_util::GetAccountIdFromProfile(profile())); | 2430 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2429 const AccountId account_id2( | 2431 const AccountId account_id2( |
| 2430 multi_user_util::GetAccountIdFromProfile(profile2)); | 2432 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2431 SwitchActiveUser(account_id2); | 2433 SwitchActiveUser(account_id2); |
| 2432 { | 2434 { |
| 2433 // Create a "windowed gmail app". | 2435 // Create a "windowed gmail app". |
| 2434 std::unique_ptr<V1App> v1_app( | 2436 std::unique_ptr<V1App> v1_app( |
| 2435 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); | 2437 CreateRunningV1App(profile(), extension_misc::kGmailAppId, kGmailUrl)); |
| 2436 EXPECT_EQ(2, model_->item_count()); | 2438 EXPECT_EQ(2, model_->item_count()); |
| 2437 | 2439 |
| 2438 // However - switching to the user should show it. | 2440 // However - switching to the user should show it. |
| 2439 SwitchActiveUser(account_id); | 2441 SwitchActiveUser(account_id); |
| 2440 EXPECT_EQ(3, model_->item_count()); | 2442 EXPECT_EQ(3, model_->item_count()); |
| 2441 | 2443 |
| 2442 // Second test: Remove the app when the user is not active and see that it | 2444 // Second test: Remove the app when the user is not active and see that it |
| 2443 // works. | 2445 // works. |
| 2444 SwitchActiveUser(account_id2); | 2446 SwitchActiveUser(account_id2); |
| 2445 EXPECT_EQ(2, model_->item_count()); | 2447 EXPECT_EQ(2, model_->item_count()); |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 EXPECT_EQ(2, model_->item_count()); | 2991 EXPECT_EQ(2, model_->item_count()); |
| 2990 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 2992 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 2991 | 2993 |
| 2992 // Installing |extension3_| adds it to the launcher. | 2994 // Installing |extension3_| adds it to the launcher. |
| 2993 const ash::ShelfID gmail_id(extension3_->id()); | 2995 const ash::ShelfID gmail_id(extension3_->id()); |
| 2994 extension_service_->AddExtension(extension3_.get()); | 2996 extension_service_->AddExtension(extension3_.get()); |
| 2995 EXPECT_EQ(3, model_->item_count()); | 2997 EXPECT_EQ(3, model_->item_count()); |
| 2996 int gmail_index = model_->ItemIndexByID(gmail_id); | 2998 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 2997 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | 2999 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); |
| 2998 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3000 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 2999 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 3001 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3000 | 3002 |
| 3001 // Check the menu content. | 3003 // Check the menu content. |
| 3002 ash::ShelfItem item_browser; | 3004 ash::ShelfItem item_browser; |
| 3003 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 3005 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 3004 item_browser.id = | 3006 item_browser.id = |
| 3005 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 3007 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 3006 | 3008 |
| 3007 ash::ShelfItem item_gmail; | 3009 ash::ShelfItem item_gmail; |
| 3008 item_gmail.type = ash::TYPE_PINNED_APP; | 3010 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3009 item_gmail.id = gmail_id; | 3011 item_gmail.id = gmail_id; |
| 3010 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); | 3012 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3011 | 3013 |
| 3012 // Set the gmail URL to a new tab. | 3014 // Set the gmail URL to a new tab. |
| 3013 base::string16 title1 = ASCIIToUTF16("Test1"); | 3015 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3014 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3016 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3015 | 3017 |
| 3016 base::string16 one_menu_item[] = {title1}; | 3018 base::string16 one_menu_item[] = {title1}; |
| 3017 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); | 3019 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); |
| 3018 | 3020 |
| 3019 // Create one empty tab. | 3021 // Create one empty tab. |
| 3020 chrome::NewTab(browser()); | 3022 chrome::NewTab(browser()); |
| 3021 base::string16 title2 = ASCIIToUTF16("Test2"); | 3023 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3022 NavigateAndCommitActiveTabWithTitle(browser(), GURL("https://bla"), title2); | 3024 NavigateAndCommitActiveTabWithTitle(browser(), GURL("https://bla"), title2); |
| 3023 | 3025 |
| 3024 // and another one with another gmail instance. | 3026 // and another one with another gmail instance. |
| 3025 chrome::NewTab(browser()); | 3027 chrome::NewTab(browser()); |
| 3026 base::string16 title3 = ASCIIToUTF16("Test3"); | 3028 base::string16 title3 = ASCIIToUTF16("Test3"); |
| 3027 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3); | 3029 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title3); |
| 3028 base::string16 two_menu_items[] = {title1, title3}; | 3030 base::string16 two_menu_items[] = {title1, title3}; |
| 3029 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); | 3031 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3030 | 3032 |
| 3031 // Even though the item is in the V1 app list, it should also be in the | 3033 // Even though the item is in the V1 app list, it should also be in the |
| 3032 // browser list. | 3034 // browser list. |
| 3033 base::string16 browser_menu_item[] = {title3}; | 3035 base::string16 browser_menu_item[] = {title3}; |
| 3034 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item); | 3036 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item); |
| 3035 | 3037 |
| 3036 // Test that closing of (all) the item(s) does work (and all menus get | 3038 // Test that closing of (all) the item(s) does work (and all menus get |
| 3037 // updated properly). | 3039 // updated properly). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3049 InitLauncherController(); | 3051 InitLauncherController(); |
| 3050 chrome::NewTab(browser()); | 3052 chrome::NewTab(browser()); |
| 3051 | 3053 |
| 3052 // Installing |extension3_| adds it to the launcher. | 3054 // Installing |extension3_| adds it to the launcher. |
| 3053 const ash::ShelfID gmail_id(extension3_->id()); | 3055 const ash::ShelfID gmail_id(extension3_->id()); |
| 3054 extension_service_->AddExtension(extension3_.get()); | 3056 extension_service_->AddExtension(extension3_.get()); |
| 3055 EXPECT_EQ(3, model_->item_count()); | 3057 EXPECT_EQ(3, model_->item_count()); |
| 3056 int gmail_index = model_->ItemIndexByID(gmail_id); | 3058 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 3057 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | 3059 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); |
| 3058 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3060 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3059 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 3061 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3060 | 3062 |
| 3061 // Check the menu content. | 3063 // Check the menu content. |
| 3062 ash::ShelfItem item_browser; | 3064 ash::ShelfItem item_browser; |
| 3063 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 3065 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 3064 item_browser.id = | 3066 item_browser.id = |
| 3065 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 3067 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 3066 | 3068 |
| 3067 ash::ShelfItem item_gmail; | 3069 ash::ShelfItem item_gmail; |
| 3068 item_gmail.type = ash::TYPE_PINNED_APP; | 3070 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3069 item_gmail.id = gmail_id; | 3071 item_gmail.id = gmail_id; |
| 3070 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); | 3072 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3071 | 3073 |
| 3072 // Set the gmail URL to a new tab. | 3074 // Set the gmail URL to a new tab. |
| 3073 base::string16 title1 = ASCIIToUTF16("Test1"); | 3075 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3074 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3076 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3075 | 3077 |
| 3076 base::string16 one_menu_item[] = {title1}; | 3078 base::string16 one_menu_item[] = {title1}; |
| 3077 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); | 3079 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); |
| 3078 | 3080 |
| 3079 // Create a second profile and switch to that user. | 3081 // Create a second profile and switch to that user. |
| 3080 std::string user2 = "user2"; | 3082 std::string user2 = "user2"; |
| 3081 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 3083 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 3082 const AccountId account_id2( | 3084 const AccountId account_id2( |
| 3083 multi_user_util::GetAccountIdFromProfile(profile2)); | 3085 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 3084 SwitchActiveUser(account_id2); | 3086 SwitchActiveUser(account_id2); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3311 } | 3313 } |
| 3312 | 3314 |
| 3313 // Checks that the generated menu list properly activates items. | 3315 // Checks that the generated menu list properly activates items. |
| 3314 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { | 3316 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { |
| 3315 InitLauncherControllerWithBrowser(); | 3317 InitLauncherControllerWithBrowser(); |
| 3316 | 3318 |
| 3317 // Add |extension3_| to the launcher and add two items. | 3319 // Add |extension3_| to the launcher and add two items. |
| 3318 GURL gmail = GURL("https://mail.google.com/mail/u"); | 3320 GURL gmail = GURL("https://mail.google.com/mail/u"); |
| 3319 const ash::ShelfID gmail_id(extension3_->id()); | 3321 const ash::ShelfID gmail_id(extension3_->id()); |
| 3320 extension_service_->AddExtension(extension3_.get()); | 3322 extension_service_->AddExtension(extension3_.get()); |
| 3321 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 3323 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3322 base::string16 title1 = ASCIIToUTF16("Test1"); | 3324 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3323 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3325 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3324 chrome::NewTab(browser()); | 3326 chrome::NewTab(browser()); |
| 3325 base::string16 title2 = ASCIIToUTF16("Test2"); | 3327 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3326 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3328 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title2); |
| 3327 | 3329 |
| 3328 // Check that the menu is properly set. | 3330 // Check that the menu is properly set. |
| 3329 ash::ShelfItem item_gmail; | 3331 ash::ShelfItem item_gmail; |
| 3330 item_gmail.type = ash::TYPE_PINNED_APP; | 3332 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3331 item_gmail.id = gmail_id; | 3333 item_gmail.id = gmail_id; |
| 3332 base::string16 two_menu_items[] = {title1, title2}; | 3334 base::string16 two_menu_items[] = {title1, title2}; |
| 3333 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); | 3335 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3334 ash::ShelfItemDelegate* item_delegate = | 3336 ash::ShelfItemDelegate* item_delegate = |
| 3335 model_->GetShelfItemDelegate(gmail_id); | 3337 model_->GetShelfItemDelegate(gmail_id); |
| 3336 ASSERT_TRUE(item_delegate); | 3338 ASSERT_TRUE(item_delegate); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3359 } | 3361 } |
| 3360 | 3362 |
| 3361 // Checks that the generated menu list properly deletes items. | 3363 // Checks that the generated menu list properly deletes items. |
| 3362 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { | 3364 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { |
| 3363 InitLauncherControllerWithBrowser(); | 3365 InitLauncherControllerWithBrowser(); |
| 3364 | 3366 |
| 3365 // Add |extension3_| to the launcher and add two items. | 3367 // Add |extension3_| to the launcher and add two items. |
| 3366 GURL gmail = GURL("https://mail.google.com/mail/u"); | 3368 GURL gmail = GURL("https://mail.google.com/mail/u"); |
| 3367 const ash::ShelfID gmail_id(extension3_->id()); | 3369 const ash::ShelfID gmail_id(extension3_->id()); |
| 3368 extension_service_->AddExtension(extension3_.get()); | 3370 extension_service_->AddExtension(extension3_.get()); |
| 3369 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 3371 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3370 base::string16 title1 = ASCIIToUTF16("Test1"); | 3372 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3371 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3373 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3372 chrome::NewTab(browser()); | 3374 chrome::NewTab(browser()); |
| 3373 base::string16 title2 = ASCIIToUTF16("Test2"); | 3375 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3374 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3376 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title2); |
| 3375 | 3377 |
| 3376 // Check that the menu is properly set. | 3378 // Check that the menu is properly set. |
| 3377 ash::ShelfItem item_gmail; | 3379 ash::ShelfItem item_gmail; |
| 3378 item_gmail.type = ash::TYPE_PINNED_APP; | 3380 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3379 item_gmail.id = gmail_id; | 3381 item_gmail.id = gmail_id; |
| 3380 base::string16 two_menu_items[] = {title1, title2}; | 3382 base::string16 two_menu_items[] = {title1, title2}; |
| 3381 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); | 3383 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3382 | 3384 |
| 3383 ash::ShelfItemDelegate* item_delegate = | 3385 ash::ShelfItemDelegate* item_delegate = |
| 3384 model_->GetShelfItemDelegate(gmail_id); | 3386 model_->GetShelfItemDelegate(gmail_id); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3444 } | 3446 } |
| 3445 | 3447 |
| 3446 // Tests that the Gmail extension matches more than the app itself claims with | 3448 // Tests that the Gmail extension matches more than the app itself claims with |
| 3447 // the manifest file. | 3449 // the manifest file. |
| 3448 TEST_F(ChromeLauncherControllerTest, GmailMatching) { | 3450 TEST_F(ChromeLauncherControllerTest, GmailMatching) { |
| 3449 InitLauncherControllerWithBrowser(); | 3451 InitLauncherControllerWithBrowser(); |
| 3450 | 3452 |
| 3451 // Create a Gmail browser tab. | 3453 // Create a Gmail browser tab. |
| 3452 chrome::NewTab(browser()); | 3454 chrome::NewTab(browser()); |
| 3453 base::string16 title = ASCIIToUTF16("Test"); | 3455 base::string16 title = ASCIIToUTF16("Test"); |
| 3454 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); | 3456 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title); |
| 3455 content::WebContents* content = | 3457 content::WebContents* content = |
| 3456 browser()->tab_strip_model()->GetActiveWebContents(); | 3458 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3457 | 3459 |
| 3458 // Check that the launcher controller does not recognize the running app. | 3460 // Check that the launcher controller does not recognize the running app. |
| 3459 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 3461 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 3460 | 3462 |
| 3461 // Installing |extension3_| adds it to the launcher. | 3463 // Installing |extension3_| adds it to the launcher. |
| 3462 const ash::ShelfID gmail_id(extension3_->id()); | 3464 const ash::ShelfID gmail_id(extension3_->id()); |
| 3463 extension_service_->AddExtension(extension3_.get()); | 3465 extension_service_->AddExtension(extension3_.get()); |
| 3464 EXPECT_EQ(3, model_->item_count()); | 3466 EXPECT_EQ(3, model_->item_count()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3477 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); | 3479 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); |
| 3478 } | 3480 } |
| 3479 | 3481 |
| 3480 // Tests that the Gmail extension does not match the offline verison. | 3482 // Tests that the Gmail extension does not match the offline verison. |
| 3481 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) { | 3483 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) { |
| 3482 InitLauncherControllerWithBrowser(); | 3484 InitLauncherControllerWithBrowser(); |
| 3483 | 3485 |
| 3484 // Create a Gmail browser tab. | 3486 // Create a Gmail browser tab. |
| 3485 chrome::NewTab(browser()); | 3487 chrome::NewTab(browser()); |
| 3486 base::string16 title = ASCIIToUTF16("Test"); | 3488 base::string16 title = ASCIIToUTF16("Test"); |
| 3487 NavigateAndCommitActiveTabWithTitle(browser(), GURL(offline_gmail_url), | 3489 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kOfflineGmailUrl), title); |
| 3488 title); | |
| 3489 content::WebContents* content = | 3490 content::WebContents* content = |
| 3490 browser()->tab_strip_model()->GetActiveWebContents(); | 3491 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3491 | 3492 |
| 3492 // Installing |extension3_| adds it to the launcher. | 3493 // Installing |extension3_| adds it to the launcher. |
| 3493 const ash::ShelfID gmail_id(extension3_->id()); | 3494 const ash::ShelfID gmail_id(extension3_->id()); |
| 3494 extension_service_->AddExtension(extension3_.get()); | 3495 extension_service_->AddExtension(extension3_.get()); |
| 3495 EXPECT_EQ(3, model_->item_count()); | 3496 EXPECT_EQ(3, model_->item_count()); |
| 3496 int gmail_index = model_->ItemIndexByID(gmail_id); | 3497 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 3497 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | 3498 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); |
| 3498 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3499 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4256 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4257 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4257 shelf_controller->auto_hide()); | 4258 shelf_controller->auto_hide()); |
| 4258 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4259 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4259 | 4260 |
| 4260 PrefService* prefs = profile()->GetTestingPrefService(); | 4261 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4261 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4263 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4263 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4265 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4265 } | 4266 } |
| OLD | NEW |