OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_browser_event_router.h" | 6 #include "chrome/browser/extensions/extension_browser_event_router.h" |
7 #include "chrome/browser/extensions/extension_tabs_module.h" | 7 #include "chrome/browser/extensions/extension_tabs_module.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 browser()->GetSelectedTabContents()->controller().session_id().id(); | 33 browser()->GetSelectedTabContents()->controller().session_id().id(); |
34 ExtensionAction* action = extension->page_action(); | 34 ExtensionAction* action = extension->page_action(); |
35 ASSERT_TRUE(action); | 35 ASSERT_TRUE(action); |
36 EXPECT_EQ("Modified", action->GetTitle(tab_id)); | 36 EXPECT_EQ("Modified", action->GetTitle(tab_id)); |
37 | 37 |
38 { | 38 { |
39 // Simulate the page action being clicked. | 39 // Simulate the page action being clicked. |
40 ResultCatcher catcher; | 40 ResultCatcher catcher; |
41 int tab_id = | 41 int tab_id = |
42 ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); | 42 ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); |
43 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 43 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 44 service->browser_event_router()->PageActionExecuted( |
44 browser()->profile(), extension->id(), "", tab_id, "", 0); | 45 browser()->profile(), extension->id(), "", tab_id, "", 0); |
45 EXPECT_TRUE(catcher.GetNextResult()); | 46 EXPECT_TRUE(catcher.GetNextResult()); |
46 } | 47 } |
47 | 48 |
48 { | 49 { |
49 // Tell the extension to update the page action state again. | 50 // Tell the extension to update the page action state again. |
50 ResultCatcher catcher; | 51 ResultCatcher catcher; |
51 ui_test_utils::NavigateToURL(browser(), | 52 ui_test_utils::NavigateToURL(browser(), |
52 GURL(extension->GetResourceURL("update2.html"))); | 53 GURL(extension->GetResourceURL("update2.html"))); |
53 ASSERT_TRUE(catcher.GetNextResult()); | 54 ASSERT_TRUE(catcher.GetNextResult()); |
(...skipping 16 matching lines...) Expand all Loading... |
70 ExtensionAction* page_action = extension->page_action(); | 71 ExtensionAction* page_action = extension->page_action(); |
71 ASSERT_TRUE(page_action) | 72 ASSERT_TRUE(page_action) |
72 << "Page action test extension should have a page action."; | 73 << "Page action test extension should have a page action."; |
73 | 74 |
74 ASSERT_FALSE(page_action->HasPopup(tab_id)); | 75 ASSERT_FALSE(page_action->HasPopup(tab_id)); |
75 | 76 |
76 // Simulate the page action being clicked. The resulting event should | 77 // Simulate the page action being clicked. The resulting event should |
77 // install a page action popup. | 78 // install a page action popup. |
78 { | 79 { |
79 ResultCatcher catcher; | 80 ResultCatcher catcher; |
80 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 81 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 82 service->browser_event_router()->PageActionExecuted( |
81 browser()->profile(), extension->id(), "action", tab_id, "", 1); | 83 browser()->profile(), extension->id(), "action", tab_id, "", 1); |
82 ASSERT_TRUE(catcher.GetNextResult()); | 84 ASSERT_TRUE(catcher.GetNextResult()); |
83 } | 85 } |
84 | 86 |
85 ASSERT_TRUE(page_action->HasPopup(tab_id)) | 87 ASSERT_TRUE(page_action->HasPopup(tab_id)) |
86 << "Clicking on the page action should have caused a popup to be added."; | 88 << "Clicking on the page action should have caused a popup to be added."; |
87 | 89 |
88 ASSERT_STREQ("/a_popup.html", | 90 ASSERT_STREQ("/a_popup.html", |
89 page_action->GetPopupUrl(tab_id).path().c_str()); | 91 page_action->GetPopupUrl(tab_id).path().c_str()); |
90 | 92 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ui_test_utils::NavigateToURL(browser(), | 147 ui_test_utils::NavigateToURL(browser(), |
146 GURL(extension->GetResourceURL("page.html"))); | 148 GURL(extension->GetResourceURL("page.html"))); |
147 ASSERT_TRUE(catcher.GetNextResult()); | 149 ASSERT_TRUE(catcher.GetNextResult()); |
148 } | 150 } |
149 | 151 |
150 // Simulate the page action being clicked. | 152 // Simulate the page action being clicked. |
151 { | 153 { |
152 ResultCatcher catcher; | 154 ResultCatcher catcher; |
153 int tab_id = | 155 int tab_id = |
154 ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); | 156 ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); |
155 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 157 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 158 service->browser_event_router()->PageActionExecuted( |
156 browser()->profile(), extension->id(), "action", tab_id, "", 1); | 159 browser()->profile(), extension->id(), "action", tab_id, "", 1); |
157 EXPECT_TRUE(catcher.GetNextResult()); | 160 EXPECT_TRUE(catcher.GetNextResult()); |
158 } | 161 } |
159 } | 162 } |
160 | 163 |
161 // Tests popups in page actions. | 164 // Tests popups in page actions. |
162 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ShowPageActionPopup) { | 165 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ShowPageActionPopup) { |
163 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; | 166 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; |
164 const Extension* extension = GetSingleLoadedExtension(); | 167 const Extension* extension = GetSingleLoadedExtension(); |
165 ASSERT_TRUE(extension) << message_; | 168 ASSERT_TRUE(extension) << message_; |
(...skipping 14 matching lines...) Expand all Loading... |
180 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TestCrash57333) { | 183 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TestCrash57333) { |
181 // Load extension A. | 184 // Load extension A. |
182 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("page_action") | 185 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("page_action") |
183 .AppendASCII("crash_57333") | 186 .AppendASCII("crash_57333") |
184 .AppendASCII("Extension1"))); | 187 .AppendASCII("Extension1"))); |
185 // Load extension B. | 188 // Load extension B. |
186 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("page_action") | 189 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("page_action") |
187 .AppendASCII("crash_57333") | 190 .AppendASCII("crash_57333") |
188 .AppendASCII("Extension2"))); | 191 .AppendASCII("Extension2"))); |
189 } | 192 } |
OLD | NEW |