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 |
102 // Get the generation ID of the original SkBitmap. This will be the default | |
103 // browser action icon. | |
104 uint32_t prev_id = extension->browser_action()->GetIcon(0).getGenerationID(); | |
102 | 105 |
103 // Tell the extension to update the icon using setIcon({imageData:...}). | 106 // Tell the extension to update the icon using setIcon({imageData:...}). |
104 ResultCatcher catcher; | 107 ResultCatcher catcher; |
105 ui_test_utils::NavigateToURL(browser(), | 108 ui_test_utils::NavigateToURL(browser(), |
106 GURL(extension->GetResourceURL("update.html"))); | 109 GURL(extension->GetResourceURL("update.html"))); |
107 ASSERT_TRUE(catcher.GetNextResult()); | 110 ASSERT_TRUE(catcher.GetNextResult()); |
108 | 111 |
109 // Test that we received the changes. | 112 // Test that we received the changes. |
110 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); | 113 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); |
111 | 114 |
115 // Test to make sure the images are different. | |
116 EXPECT_TRUE(prev_id != | |
117 extension->browser_action()->GetIcon(0).getGenerationID()); | |
118 | |
119 // Reset prev_id for next test. | |
Devlin
2012/02/25 18:41:00
Please use proper grammar in comments.
cduvall
2012/02/25 19:23:06
Done.
| |
120 prev_id = extension->browser_action()->GetIcon(0).getGenerationID(); | |
121 | |
112 // Tell the extension to update using setIcon({path:...}); | 122 // Tell the extension to update using setIcon({path:...}); |
Devlin
2012/02/25 18:41:00
I know it's not your code, but you should change t
cduvall
2012/02/25 19:23:06
Done.
| |
113 ui_test_utils::NavigateToURL(browser(), | 123 ui_test_utils::NavigateToURL(browser(), |
114 GURL(extension->GetResourceURL("update2.html"))); | 124 GURL(extension->GetResourceURL("update2.html"))); |
115 ASSERT_TRUE(catcher.GetNextResult()); | 125 ASSERT_TRUE(catcher.GetNextResult()); |
116 | 126 |
117 // Test that we received the changes. | 127 // Test that we received the changes. |
118 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); | 128 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); |
119 | 129 |
130 // Test to make sure the images are different. | |
Devlin
2012/02/25 18:41:00
The second set of comments seems superfluous, and
cduvall
2012/02/25 19:23:06
Done.
| |
131 EXPECT_TRUE(prev_id != | |
132 extension->browser_action()->GetIcon(0).getGenerationID()); | |
133 | |
120 // TODO(aa): Would be nice here to actually compare that the pixels change. | 134 // TODO(aa): Would be nice here to actually compare that the pixels change. |
Devlin
2012/02/25 18:41:00
Isn't this what we are doing now? It's safe to re
cduvall
2012/02/25 19:23:06
Done.
| |
121 } | 135 } |
122 | 136 |
123 // This test is flaky as per http://crbug.com/74557. | 137 // This test is flaky as per http://crbug.com/74557. |
124 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, | 138 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
125 DISABLED_TabSpecificBrowserActionState) { | 139 DISABLED_TabSpecificBrowserActionState) { |
126 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << | 140 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << |
127 message_; | 141 message_; |
128 const Extension* extension = GetSingleLoadedExtension(); | 142 const Extension* extension = GetSingleLoadedExtension(); |
129 ASSERT_TRUE(extension) << message_; | 143 ASSERT_TRUE(extension) << message_; |
130 | 144 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 BrowserActionExecuted( | 415 BrowserActionExecuted( |
402 browser()->profile(), action->extension_id(), browser()); | 416 browser()->profile(), action->extension_id(), browser()); |
403 | 417 |
404 // It can take a moment for the background page to actually get destroyed | 418 // 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 | 419 // so we wait for the notification before checking that it's really gone |
406 // and the badge text has been set. | 420 // and the badge text has been set. |
407 host_destroyed_observer.Wait(); | 421 host_destroyed_observer.Wait(); |
408 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 422 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
409 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 423 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
410 } | 424 } |
OLD | NEW |