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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId)); | 70 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId)); |
71 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 71 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
72 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), | 72 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), |
73 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); | 73 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId)); |
74 | 74 |
75 // Simulate the browser action being clicked. | 75 // Simulate the browser action being clicked. |
76 ui_test_utils::NavigateToURL(browser(), | 76 ui_test_utils::NavigateToURL(browser(), |
77 test_server()->GetURL("files/extensions/test_file.txt")); | 77 test_server()->GetURL("files/extensions/test_file.txt")); |
78 | 78 |
79 ExtensionService* service = browser()->profile()->GetExtensionService(); | 79 ExtensionService* service = browser()->profile()->GetExtensionService(); |
80 service->toolbar_model()->ExecuteBrowserAction( | 80 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
81 action->extension_id(), browser()); | |
82 | 81 |
83 // Verify the command worked. | 82 // Verify the command worked. |
84 WebContents* tab = browser()->GetSelectedWebContents(); | 83 WebContents* tab = browser()->GetSelectedWebContents(); |
85 bool result = false; | 84 bool result = false; |
86 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 85 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
87 tab->GetRenderViewHost(), L"", | 86 tab->GetRenderViewHost(), L"", |
88 L"setInterval(function(){" | 87 L"setInterval(function(){" |
89 L" if(document.body.bgColor == 'red'){" | 88 L" if(document.body.bgColor == 'red'){" |
90 L" window.domAutomationController.send(true)}}, 100)", | 89 L" window.domAutomationController.send(true)}}, 100)", |
91 &result)); | 90 &result)); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id())); | 394 ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id())); |
396 ExtensionAction* action = extension->browser_action(); | 395 ExtensionAction* action = extension->browser_action(); |
397 ASSERT_EQ("", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 396 ASSERT_EQ("", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
398 | 397 |
399 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( | 398 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( |
400 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 399 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
401 content::NotificationService::AllSources()); | 400 content::NotificationService::AllSources()); |
402 | 401 |
403 // Click the browser action. | 402 // Click the browser action. |
404 browser()->profile()->GetExtensionService()->toolbar_model()-> | 403 browser()->profile()->GetExtensionService()->toolbar_model()-> |
405 ExecuteBrowserAction(action->extension_id(), browser()); | 404 ExecuteBrowserAction(extension, browser(), NULL); |
406 | 405 |
407 // It can take a moment for the background page to actually get destroyed | 406 // It can take a moment for the background page to actually get destroyed |
408 // so we wait for the notification before checking that it's really gone | 407 // so we wait for the notification before checking that it's really gone |
409 // and the badge text has been set. | 408 // and the badge text has been set. |
410 host_destroyed_observer.Wait(); | 409 host_destroyed_observer.Wait(); |
411 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 410 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
412 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 411 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
413 } | 412 } |
414 | 413 |
415 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BadgeBackgroundColor) { | 414 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BadgeBackgroundColor) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 ResultCatcher catcher; | 458 ResultCatcher catcher; |
460 ui_test_utils::NavigateToURL(browser(), | 459 ui_test_utils::NavigateToURL(browser(), |
461 GURL(extension->GetResourceURL("update.html"))); | 460 GURL(extension->GetResourceURL("update.html"))); |
462 ASSERT_TRUE(catcher.GetNextResult()); | 461 ASSERT_TRUE(catcher.GetNextResult()); |
463 | 462 |
464 // Test the getters for a specific tab. | 463 // Test the getters for a specific tab. |
465 ui_test_utils::NavigateToURL(browser(), | 464 ui_test_utils::NavigateToURL(browser(), |
466 GURL(extension->GetResourceURL("update2.html"))); | 465 GURL(extension->GetResourceURL("update2.html"))); |
467 ASSERT_TRUE(catcher.GetNextResult()); | 466 ASSERT_TRUE(catcher.GetNextResult()); |
468 } | 467 } |
OLD | NEW |