Chromium Code Reviews| 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 |
| 112 // Tell the extension to update using setIcon({path:...}); | 115 // Test to make sure the images are different. |
|
Aaron Boodman
2012/03/02 20:16:39
If you just want to ensure that the icons are diff
cduvall
2012/03/02 22:18:30
That would also work. I just wanted to make sure t
Aaron Boodman
2012/03/02 22:34:46
Hm, I thought there was functionality in SkBitmap
| |
| 116 EXPECT_TRUE(prev_id != | |
| 117 extension->browser_action()->GetIcon(0).getGenerationID()); | |
| 118 | |
| 119 // Reset prev_id to use in the next test and repeat the process using | |
| 120 // setIcon({path:...}). | |
| 121 prev_id = extension->browser_action()->GetIcon(0).getGenerationID(); | |
| 122 | |
| 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 | |
| 117 // Test that we received the changes. | |
| 118 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); | 126 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); |
| 119 | 127 EXPECT_TRUE(prev_id != |
| 120 // TODO(aa): Would be nice here to actually compare that the pixels change. | 128 extension->browser_action()->GetIcon(0).getGenerationID()); |
| 121 } | 129 } |
| 122 | 130 |
| 123 // This test is flaky as per http://crbug.com/74557. | 131 // This test is flaky as per http://crbug.com/74557. |
| 124 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, | 132 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, |
| 125 DISABLED_TabSpecificBrowserActionState) { | 133 DISABLED_TabSpecificBrowserActionState) { |
| 126 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << | 134 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << |
| 127 message_; | 135 message_; |
| 128 const Extension* extension = GetSingleLoadedExtension(); | 136 const Extension* extension = GetSingleLoadedExtension(); |
| 129 ASSERT_TRUE(extension) << message_; | 137 ASSERT_TRUE(extension) << message_; |
| 130 | 138 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 BrowserActionExecuted( | 409 BrowserActionExecuted( |
| 402 browser()->profile(), action->extension_id(), browser()); | 410 browser()->profile(), action->extension_id(), browser()); |
| 403 | 411 |
| 404 // It can take a moment for the background page to actually get destroyed | 412 // 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 | 413 // so we wait for the notification before checking that it's really gone |
| 406 // and the badge text has been set. | 414 // and the badge text has been set. |
| 407 host_destroyed_observer.Wait(); | 415 host_destroyed_observer.Wait(); |
| 408 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 416 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
| 409 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 417 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
| 410 } | 418 } |
| OLD | NEW |