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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 L" window.domAutomationController.send(true)}}, 100)", | 89 L" window.domAutomationController.send(true)}}, 100)", |
90 &result)); | 90 &result)); |
91 ASSERT_TRUE(result); | 91 ASSERT_TRUE(result); |
92 } | 92 } |
93 | 93 |
94 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { | 94 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { |
95 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; | 95 ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; |
96 const Extension* extension = GetSingleLoadedExtension(); | 96 const Extension* extension = GetSingleLoadedExtension(); |
97 ASSERT_TRUE(extension) << message_; | 97 ASSERT_TRUE(extension) << message_; |
98 | 98 |
99 // Test that there is a browser action in the toolbar and that it has no icon. | 99 // Test that there is a browser action in the toolbar. |
100 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions()); | 100 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions()); |
101 EXPECT_FALSE(GetBrowserActionsBar().HasIcon(0)); | 101 EXPECT_FALSE(GetBrowserActionsBar().HasIcon(0)); |
102 | 102 |
103 // Tell the extension to update the icon using setIcon({imageData:...}). | 103 // Tell the extension to update the icon using setIcon({imageData:...}). |
104 ResultCatcher catcher; | 104 ResultCatcher catcher; |
105 ui_test_utils::NavigateToURL(browser(), | 105 ui_test_utils::NavigateToURL(browser(), |
106 GURL(extension->GetResourceURL("update.html"))); | 106 GURL(extension->GetResourceURL("update.html"))); |
107 ASSERT_TRUE(catcher.GetNextResult()); | 107 ASSERT_TRUE(catcher.GetNextResult()); |
108 | 108 |
109 // Test that we received the changes. | 109 // Test that we received the changes. |
110 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); | 110 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); |
111 | 111 |
112 // Tell the extension to update using setIcon({path:...}); | 112 // Set prev_id which holds the id of the previous image, and use it in the |
| 113 // next test to see if the image changes. |
| 114 uint32_t prev_id = extension->browser_action()->GetIcon(0).getGenerationID(); |
| 115 |
| 116 // Tell the extension to update the icon using setIcon({path:...}). |
113 ui_test_utils::NavigateToURL(browser(), | 117 ui_test_utils::NavigateToURL(browser(), |
114 GURL(extension->GetResourceURL("update2.html"))); | 118 GURL(extension->GetResourceURL("update2.html"))); |
115 ASSERT_TRUE(catcher.GetNextResult()); | 119 ASSERT_TRUE(catcher.GetNextResult()); |
116 | |
117 // Test that we received the changes. | |
118 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); | 120 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); |
119 | 121 EXPECT_TRUE(prev_id != |
120 // TODO(aa): Would be nice here to actually compare that the pixels change. | 122 extension->browser_action()->GetIcon(0).getGenerationID()); |
121 } | 123 } |
122 | 124 |
123 // This test is flaky as per http://crbug.com/74557. | 125 // This test is flaky as per http://crbug.com/74557. |
124 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, | 126 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
125 DISABLED_TabSpecificBrowserActionState) { | 127 DISABLED_TabSpecificBrowserActionState) { |
126 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << | 128 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << |
127 message_; | 129 message_; |
128 const Extension* extension = GetSingleLoadedExtension(); | 130 const Extension* extension = GetSingleLoadedExtension(); |
129 ASSERT_TRUE(extension) << message_; | 131 ASSERT_TRUE(extension) << message_; |
130 | 132 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 BrowserActionExecuted( | 403 BrowserActionExecuted( |
402 browser()->profile(), action->extension_id(), browser()); | 404 browser()->profile(), action->extension_id(), browser()); |
403 | 405 |
404 // 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 |
405 // 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 |
406 // and the badge text has been set. | 408 // and the badge text has been set. |
407 host_destroyed_observer.Wait(); | 409 host_destroyed_observer.Wait(); |
408 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 410 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
409 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 411 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
410 } | 412 } |
OLD | NEW |