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

Side by Side Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 10412052: Pull browser action click logic into ToolbarModelController, so that when I (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698