| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 9 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
| 10 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ExtensionAction* action = | 84 ExtensionAction* action = |
| 85 extension_action_manager()->GetBrowserAction(*extension); | 85 extension_action_manager()->GetBrowserAction(*extension); |
| 86 ASSERT_TRUE(action); | 86 ASSERT_TRUE(action); |
| 87 EXPECT_EQ("Modified", action->GetTitle(tab_id)); | 87 EXPECT_EQ("Modified", action->GetTitle(tab_id)); |
| 88 | 88 |
| 89 { | 89 { |
| 90 // Simulate the page action being clicked. | 90 // Simulate the page action being clicked. |
| 91 ResultCatcher catcher; | 91 ResultCatcher catcher; |
| 92 ExtensionService* service = extensions::ExtensionSystem::Get( | 92 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 93 browser()->profile())->extension_service(); | 93 browser()->profile())->extension_service(); |
| 94 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 94 service->toolbar_model()->ExecuteBrowserAction( |
| 95 extension, browser(), NULL, true); |
| 95 EXPECT_TRUE(catcher.GetNextResult()); | 96 EXPECT_TRUE(catcher.GetNextResult()); |
| 96 } | 97 } |
| 97 | 98 |
| 98 { | 99 { |
| 99 // Tell the extension to update the page action state again. | 100 // Tell the extension to update the page action state again. |
| 100 ResultCatcher catcher; | 101 ResultCatcher catcher; |
| 101 ui_test_utils::NavigateToURL(browser(), | 102 ui_test_utils::NavigateToURL(browser(), |
| 102 GURL(extension->GetResourceURL("update2.html"))); | 103 GURL(extension->GetResourceURL("update2.html"))); |
| 103 ASSERT_TRUE(catcher.GetNextResult()); | 104 ASSERT_TRUE(catcher.GetNextResult()); |
| 104 } | 105 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 128 << "Page action test extension should have a page action."; | 129 << "Page action test extension should have a page action."; |
| 129 | 130 |
| 130 ASSERT_FALSE(page_action->HasPopup(tab_id)); | 131 ASSERT_FALSE(page_action->HasPopup(tab_id)); |
| 131 | 132 |
| 132 // Simulate the page action being clicked. The resulting event should | 133 // Simulate the page action being clicked. The resulting event should |
| 133 // install a page action popup. | 134 // install a page action popup. |
| 134 { | 135 { |
| 135 ResultCatcher catcher; | 136 ResultCatcher catcher; |
| 136 ExtensionService* service = extensions::ExtensionSystem::Get( | 137 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 137 browser()->profile())->extension_service(); | 138 browser()->profile())->extension_service(); |
| 138 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 139 service->toolbar_model()->ExecuteBrowserAction( |
| 140 extension, browser(), NULL, true); |
| 139 ASSERT_TRUE(catcher.GetNextResult()); | 141 ASSERT_TRUE(catcher.GetNextResult()); |
| 140 } | 142 } |
| 141 | 143 |
| 142 ASSERT_TRUE(page_action->HasPopup(tab_id)) | 144 ASSERT_TRUE(page_action->HasPopup(tab_id)) |
| 143 << "Clicking on the page action should have caused a popup to be added."; | 145 << "Clicking on the page action should have caused a popup to be added."; |
| 144 | 146 |
| 145 ASSERT_STREQ("/a_popup.html", | 147 ASSERT_STREQ("/a_popup.html", |
| 146 page_action->GetPopupUrl(tab_id).path().c_str()); | 148 page_action->GetPopupUrl(tab_id).path().c_str()); |
| 147 | 149 |
| 148 // Now change the popup from a_popup.html to a_second_popup.html . | 150 // Now change the popup from a_popup.html to a_second_popup.html . |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; | 197 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; |
| 196 const Extension* extension = GetSingleLoadedExtension(); | 198 const Extension* extension = GetSingleLoadedExtension(); |
| 197 ASSERT_TRUE(extension) << message_; | 199 ASSERT_TRUE(extension) << message_; |
| 198 | 200 |
| 199 ResultCatcher catcher; | 201 ResultCatcher catcher; |
| 200 ui_test_utils::NavigateToURL(browser(), | 202 ui_test_utils::NavigateToURL(browser(), |
| 201 GURL(extension->GetResourceURL("update.html"))); | 203 GURL(extension->GetResourceURL("update.html"))); |
| 202 ASSERT_TRUE(catcher.GetNextResult()); | 204 ASSERT_TRUE(catcher.GetNextResult()); |
| 203 } | 205 } |
| 204 | 206 |
| 205 } | 207 } // namespace |
| 206 } // namespace extensions | 208 } // namespace extensions |
| OLD | NEW |