OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 ExtensionAction* action = GetBrowserAction(*extension); | 115 ExtensionAction* action = GetBrowserAction(*extension); |
116 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId)); | 116 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId)); |
117 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 117 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
118 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), | 118 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), |
119 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); | 119 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); |
120 | 120 |
121 // Simulate the browser action being clicked. | 121 // Simulate the browser action being clicked. |
122 ui_test_utils::NavigateToURL(browser(), | 122 ui_test_utils::NavigateToURL(browser(), |
123 test_server()->GetURL("files/extensions/test_file.txt")); | 123 test_server()->GetURL("files/extensions/test_file.txt")); |
124 | 124 |
125 ExtensionService* service = browser()->profile()->GetExtensionService(); | 125 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 126 browser()->profile())->extension_service(); |
126 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 127 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
127 | 128 |
128 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 129 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
129 } | 130 } |
130 | 131 |
131 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { | 132 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { |
132 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; | 133 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; |
133 const Extension* extension = GetSingleLoadedExtension(); | 134 const Extension* extension = GetSingleLoadedExtension(); |
134 ASSERT_TRUE(extension) << message_; | 135 ASSERT_TRUE(extension) << message_; |
135 | 136 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 480 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
480 Browser* incognito_browser = | 481 Browser* incognito_browser = |
481 new Browser(Browser::CreateParams(incognito_profile)); | 482 new Browser(Browser::CreateParams(incognito_profile)); |
482 | 483 |
483 ASSERT_EQ(0, | 484 ASSERT_EQ(0, |
484 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 485 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
485 | 486 |
486 // Now enable the extension in incognito mode, and test that the browser | 487 // Now enable the extension in incognito mode, and test that the browser |
487 // action shows up. Note that we don't update the existing window at the | 488 // action shows up. Note that we don't update the existing window at the |
488 // moment, so we just create a new one. | 489 // moment, so we just create a new one. |
489 browser()->profile()->GetExtensionService()->extension_prefs()-> | 490 extensions::ExtensionSystem::Get(browser()->profile())->extension_service()-> |
490 SetIsIncognitoEnabled(extension->id(), true); | 491 extension_prefs()->SetIsIncognitoEnabled(extension->id(), true); |
491 | 492 |
492 chrome::CloseWindow(incognito_browser); | 493 chrome::CloseWindow(incognito_browser); |
493 incognito_browser = new Browser(Browser::CreateParams(incognito_profile)); | 494 incognito_browser = new Browser(Browser::CreateParams(incognito_profile)); |
494 ASSERT_EQ(1, | 495 ASSERT_EQ(1, |
495 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 496 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
496 | 497 |
497 // TODO(mpcomplete): simulate a click and have it do the right thing in | 498 // TODO(mpcomplete): simulate a click and have it do the right thing in |
498 // incognito. | 499 // incognito. |
499 } | 500 } |
500 | 501 |
501 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) { | 502 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) { |
502 ExtensionService* service = browser()->profile()->GetExtensionService(); | 503 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 504 browser()->profile())->extension_service(); |
503 | 505 |
504 // The tooltips for each respective browser action. | 506 // The tooltips for each respective browser action. |
505 const char kTooltipA[] = "Make this page red"; | 507 const char kTooltipA[] = "Make this page red"; |
506 const char kTooltipB[] = "grow"; | 508 const char kTooltipB[] = "grow"; |
507 const char kTooltipC[] = "Test setPopup()"; | 509 const char kTooltipC[] = "Test setPopup()"; |
508 | 510 |
509 const size_t size_before = service->extensions()->size(); | 511 const size_t size_before = service->extensions()->size(); |
510 | 512 |
511 const Extension* extension_a = LoadExtension(test_data_dir_.AppendASCII( | 513 const Extension* extension_a = LoadExtension(test_data_dir_.AppendASCII( |
512 "browser_action/basics")); | 514 "browser_action/basics")); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); | 583 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); |
582 ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id())); | 584 ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id())); |
583 ExtensionAction* action = GetBrowserAction(*extension); | 585 ExtensionAction* action = GetBrowserAction(*extension); |
584 ASSERT_EQ("", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 586 ASSERT_EQ("", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
585 | 587 |
586 content::WindowedNotificationObserver host_destroyed_observer( | 588 content::WindowedNotificationObserver host_destroyed_observer( |
587 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 589 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
588 content::NotificationService::AllSources()); | 590 content::NotificationService::AllSources()); |
589 | 591 |
590 // Click the browser action. | 592 // Click the browser action. |
591 browser()->profile()->GetExtensionService()->toolbar_model()-> | 593 extensions::ExtensionSystem::Get(browser()->profile())->extension_service()-> |
592 ExecuteBrowserAction(extension, browser(), NULL); | 594 toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
593 | 595 |
594 // It can take a moment for the background page to actually get destroyed | 596 // It can take a moment for the background page to actually get destroyed |
595 // so we wait for the notification before checking that it's really gone | 597 // so we wait for the notification before checking that it's really gone |
596 // and the badge text has been set. | 598 // and the badge text has been set. |
597 host_destroyed_observer.Wait(); | 599 host_destroyed_observer.Wait(); |
598 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 600 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
599 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 601 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
600 } | 602 } |
601 | 603 |
602 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BadgeBackgroundColor) { | 604 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BadgeBackgroundColor) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 ASSERT_TRUE(catcher.GetNextResult()); | 649 ASSERT_TRUE(catcher.GetNextResult()); |
648 | 650 |
649 // Test the getters for a specific tab. | 651 // Test the getters for a specific tab. |
650 ui_test_utils::NavigateToURL(browser(), | 652 ui_test_utils::NavigateToURL(browser(), |
651 GURL(extension->GetResourceURL("update2.html"))); | 653 GURL(extension->GetResourceURL("update2.html"))); |
652 ASSERT_TRUE(catcher.GetNextResult()); | 654 ASSERT_TRUE(catcher.GetNextResult()); |
653 } | 655 } |
654 | 656 |
655 } // namespace | 657 } // namespace |
656 } // namespace extensions | 658 } // namespace extensions |
OLD | NEW |