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/browser_action_test_util.h" | 6 #include "chrome/browser/extensions/browser_action_test_util.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_browser_event_router.h" | 8 #include "chrome/browser/extensions/extension_browser_event_router.h" |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Test that we received the changes. | 74 // Test that we received the changes. |
75 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); | 75 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); |
76 ExtensionAction* action = extension->browser_action(); | 76 ExtensionAction* action = extension->browser_action(); |
77 ASSERT_TRUE(action); | 77 ASSERT_TRUE(action); |
78 EXPECT_EQ("Modified", action->GetTitle(tab_id)); | 78 EXPECT_EQ("Modified", action->GetTitle(tab_id)); |
79 | 79 |
80 { | 80 { |
81 // Simulate the page action being clicked. | 81 // Simulate the page action being clicked. |
82 ResultCatcher catcher; | 82 ResultCatcher catcher; |
83 ExtensionService* service = browser()->profile()->GetExtensionService(); | 83 ExtensionService* service = browser()->profile()->GetExtensionService(); |
84 service->toolbar_model()->ExecuteBrowserAction( | 84 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
85 extension->id(), browser()); | |
86 EXPECT_TRUE(catcher.GetNextResult()); | 85 EXPECT_TRUE(catcher.GetNextResult()); |
87 } | 86 } |
88 | 87 |
89 { | 88 { |
90 // Tell the extension to update the page action state again. | 89 // Tell the extension to update the page action state again. |
91 ResultCatcher catcher; | 90 ResultCatcher catcher; |
92 ui_test_utils::NavigateToURL(browser(), | 91 ui_test_utils::NavigateToURL(browser(), |
93 GURL(extension->GetResourceURL("update2.html"))); | 92 GURL(extension->GetResourceURL("update2.html"))); |
94 ASSERT_TRUE(catcher.GetNextResult()); | 93 ASSERT_TRUE(catcher.GetNextResult()); |
95 } | 94 } |
(...skipping 15 matching lines...) Expand all Loading... |
111 ASSERT_TRUE(page_action) | 110 ASSERT_TRUE(page_action) |
112 << "Page action test extension should have a page action."; | 111 << "Page action test extension should have a page action."; |
113 | 112 |
114 ASSERT_FALSE(page_action->HasPopup(tab_id)); | 113 ASSERT_FALSE(page_action->HasPopup(tab_id)); |
115 | 114 |
116 // Simulate the page action being clicked. The resulting event should | 115 // Simulate the page action being clicked. The resulting event should |
117 // install a page action popup. | 116 // install a page action popup. |
118 { | 117 { |
119 ResultCatcher catcher; | 118 ResultCatcher catcher; |
120 ExtensionService* service = browser()->profile()->GetExtensionService(); | 119 ExtensionService* service = browser()->profile()->GetExtensionService(); |
121 service->toolbar_model()->ExecuteBrowserAction( | 120 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
122 extension->id(), browser()); | |
123 ASSERT_TRUE(catcher.GetNextResult()); | 121 ASSERT_TRUE(catcher.GetNextResult()); |
124 } | 122 } |
125 | 123 |
126 ASSERT_TRUE(page_action->HasPopup(tab_id)) | 124 ASSERT_TRUE(page_action->HasPopup(tab_id)) |
127 << "Clicking on the page action should have caused a popup to be added."; | 125 << "Clicking on the page action should have caused a popup to be added."; |
128 | 126 |
129 ASSERT_STREQ("/a_popup.html", | 127 ASSERT_STREQ("/a_popup.html", |
130 page_action->GetPopupUrl(tab_id).path().c_str()); | 128 page_action->GetPopupUrl(tab_id).path().c_str()); |
131 | 129 |
132 // Now change the popup from a_popup.html to a_second_popup.html . | 130 // Now change the popup from a_popup.html to a_second_popup.html . |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const Extension* extension = GetSingleLoadedExtension(); | 176 const Extension* extension = GetSingleLoadedExtension(); |
179 ASSERT_TRUE(extension) << message_; | 177 ASSERT_TRUE(extension) << message_; |
180 | 178 |
181 ResultCatcher catcher; | 179 ResultCatcher catcher; |
182 ui_test_utils::NavigateToURL(browser(), | 180 ui_test_utils::NavigateToURL(browser(), |
183 GURL(extension->GetResourceURL("update.html"))); | 181 GURL(extension->GetResourceURL("update.html"))); |
184 ASSERT_TRUE(catcher.GetNextResult()); | 182 ASSERT_TRUE(catcher.GetNextResult()); |
185 } | 183 } |
186 | 184 |
187 } | 185 } |
OLD | NEW |