Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/extensions/extension_browsertests_misc.cc

Issue 1814002: Remove deprecated things from net test suite: (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/extensions/autoupdate_interceptor.h" 9 #include "chrome/browser/extensions/autoupdate_interceptor.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 11 matching lines...) Expand all
22 #endif 22 #endif
23 23
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/extensions/extension_error_reporter.h" 25 #include "chrome/common/extensions/extension_error_reporter.h"
26 #include "chrome/common/notification_service.h" 26 #include "chrome/common/notification_service.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "chrome/test/ui_test_utils.h" 28 #include "chrome/test/ui_test_utils.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 30
31 const std::string kSubscribePage = "/subscribe.html"; 31 const std::string kSubscribePage = "/subscribe.html";
32 const std::wstring kFeedPage = L"files/feeds/feed.html"; 32 const std::string kFeedPage = "files/feeds/feed.html";
33 const std::wstring kFeedPageMultiRel = L"files/feeds/feed_multi_rel.html"; 33 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html";
34 const std::wstring kNoFeedPage = L"files/feeds/no_feed.html"; 34 const std::string kNoFeedPage = "files/feeds/no_feed.html";
35 const std::wstring kValidFeed0 = L"files/feeds/feed_script.xml"; 35 const std::string kValidFeed0 = "files/feeds/feed_script.xml";
36 const std::wstring kValidFeed1 = L"files/feeds/feed1.xml"; 36 const std::string kValidFeed1 = "files/feeds/feed1.xml";
37 const std::wstring kValidFeed2 = L"files/feeds/feed2.xml"; 37 const std::string kValidFeed2 = "files/feeds/feed2.xml";
38 const std::wstring kValidFeed3 = L"files/feeds/feed3.xml"; 38 const std::string kValidFeed3 = "files/feeds/feed3.xml";
39 const std::wstring kValidFeed4 = L"files/feeds/feed4.xml"; 39 const std::string kValidFeed4 = "files/feeds/feed4.xml";
40 const std::wstring kValidFeed5 = L"files/feeds/feed5.xml"; 40 const std::string kValidFeed5 = "files/feeds/feed5.xml";
41 const std::wstring kValidFeedNoLinks = L"files/feeds/feed_nolinks.xml"; 41 const std::string kValidFeedNoLinks = "files/feeds/feed_nolinks.xml";
42 const std::wstring kInvalidFeed1 = L"files/feeds/feed_invalid1.xml"; 42 const std::string kInvalidFeed1 = "files/feeds/feed_invalid1.xml";
43 const std::wstring kInvalidFeed2 = L"files/feeds/feed_invalid2.xml"; 43 const std::string kInvalidFeed2 = "files/feeds/feed_invalid2.xml";
44 const std::wstring kLocalization = 44 const std::string kLocalization =
45 L"files/extensions/browsertest/title_localized_pa/simple.html"; 45 "files/extensions/browsertest/title_localized_pa/simple.html";
46 const std::wstring kHashPageA = 46 const std::string kHashPageA =
47 L"files/extensions/api_test/page_action/hash_change/test_page_A.html"; 47 "files/extensions/api_test/page_action/hash_change/test_page_A.html";
48 const std::wstring kHashPageAHash = kHashPageA + L"#asdf"; 48 const std::string kHashPageAHash = kHashPageA + "#asdf";
49 const std::wstring kHashPageB = 49 const std::string kHashPageB =
50 L"files/extensions/api_test/page_action/hash_change/test_page_B.html"; 50 "files/extensions/api_test/page_action/hash_change/test_page_B.html";
51 51
52 // Looks for an ExtensionHost whose URL has the given path component (including 52 // Looks for an ExtensionHost whose URL has the given path component (including
53 // leading slash). Also verifies that the expected number of hosts are loaded. 53 // leading slash). Also verifies that the expected number of hosts are loaded.
54 static ExtensionHost* FindHostWithPath(ExtensionProcessManager* manager, 54 static ExtensionHost* FindHostWithPath(ExtensionProcessManager* manager,
55 const std::string& path, 55 const std::string& path,
56 int expected_hosts) { 56 int expected_hosts) {
57 ExtensionHost* host = NULL; 57 ExtensionHost* host = NULL;
58 int num_hosts = 0; 58 int num_hosts = 0;
59 for (ExtensionProcessManager::const_iterator iter = manager->begin(); 59 for (ExtensionProcessManager::const_iterator iter = manager->begin();
60 iter != manager->end(); ++iter) { 60 iter != manager->end(); ++iter) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ASSERT_TRUE(LoadExtension( 212 ASSERT_TRUE(LoadExtension(
213 test_data_dir_.AppendASCII("browsertest") 213 test_data_dir_.AppendASCII("browsertest")
214 .AppendASCII("crash_25562"))); 214 .AppendASCII("crash_25562")));
215 215
216 ASSERT_TRUE(LoadExtension( 216 ASSERT_TRUE(LoadExtension(
217 test_data_dir_.AppendASCII("subscribe_page_action"))); 217 test_data_dir_.AppendASCII("subscribe_page_action")));
218 218
219 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0)); 219 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
220 220
221 // Navigate to the feed page. 221 // Navigate to the feed page.
222 GURL feed_url = server->TestServerPageW(kFeedPage); 222 GURL feed_url = server->TestServerPage(kFeedPage);
223 ui_test_utils::NavigateToURL(browser(), feed_url); 223 ui_test_utils::NavigateToURL(browser(), feed_url);
224 // We should now have one page action ready to go in the LocationBar. 224 // We should now have one page action ready to go in the LocationBar.
225 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 225 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
226 226
227 // Navigate to a page with no feed. 227 // Navigate to a page with no feed.
228 GURL no_feed = server->TestServerPageW(kNoFeedPage); 228 GURL no_feed = server->TestServerPage(kNoFeedPage);
229 ui_test_utils::NavigateToURL(browser(), no_feed); 229 ui_test_utils::NavigateToURL(browser(), no_feed);
230 // Make sure the page action goes away. 230 // Make sure the page action goes away.
231 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0)); 231 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
232 } 232 }
233 233
234 // Tests that we don't lose the page action icon on in-page navigations. 234 // Tests that we don't lose the page action icon on in-page navigations.
235 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionInPageNavigation) { 235 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionInPageNavigation) {
236 HTTPTestServer* server = StartHTTPServer(); 236 HTTPTestServer* server = StartHTTPServer();
237 237
238 FilePath extension_path(test_data_dir_.AppendASCII("api_test") 238 FilePath extension_path(test_data_dir_.AppendASCII("api_test")
239 .AppendASCII("page_action") 239 .AppendASCII("page_action")
240 .AppendASCII("hash_change")); 240 .AppendASCII("hash_change"));
241 ASSERT_TRUE(LoadExtension(extension_path)); 241 ASSERT_TRUE(LoadExtension(extension_path));
242 242
243 // Page action should become visible when we navigate here. 243 // Page action should become visible when we navigate here.
244 GURL feed_url = server->TestServerPageW(kHashPageA); 244 GURL feed_url = server->TestServerPage(kHashPageA);
245 ui_test_utils::NavigateToURL(browser(), feed_url); 245 ui_test_utils::NavigateToURL(browser(), feed_url);
246 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 246 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
247 247
248 // In-page navigation, page action should remain. 248 // In-page navigation, page action should remain.
249 feed_url = server->TestServerPageW(kHashPageAHash); 249 feed_url = server->TestServerPage(kHashPageAHash);
250 ui_test_utils::NavigateToURL(browser(), feed_url); 250 ui_test_utils::NavigateToURL(browser(), feed_url);
251 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 251 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
252 252
253 // Not an in-page navigation, page action should go away. 253 // Not an in-page navigation, page action should go away.
254 feed_url = server->TestServerPageW(kHashPageB); 254 feed_url = server->TestServerPage(kHashPageB);
255 ui_test_utils::NavigateToURL(browser(), feed_url); 255 ui_test_utils::NavigateToURL(browser(), feed_url);
256 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0)); 256 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
257 } 257 }
258 258
259 // Tests that the location bar forgets about unloaded page actions. 259 // Tests that the location bar forgets about unloaded page actions.
260 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UnloadPageAction) { 260 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UnloadPageAction) {
261 HTTPTestServer* server = StartHTTPServer(); 261 HTTPTestServer* server = StartHTTPServer();
262 262
263 FilePath extension_path(test_data_dir_.AppendASCII("subscribe_page_action")); 263 FilePath extension_path(test_data_dir_.AppendASCII("subscribe_page_action"));
264 ASSERT_TRUE(LoadExtension(extension_path)); 264 ASSERT_TRUE(LoadExtension(extension_path));
265 265
266 // Navigation prompts the location bar to load page actions. 266 // Navigation prompts the location bar to load page actions.
267 GURL feed_url = server->TestServerPageW(kFeedPage); 267 GURL feed_url = server->TestServerPage(kFeedPage);
268 ui_test_utils::NavigateToURL(browser(), feed_url); 268 ui_test_utils::NavigateToURL(browser(), feed_url);
269 ASSERT_TRUE(WaitForPageActionCountChangeTo(1)); 269 ASSERT_TRUE(WaitForPageActionCountChangeTo(1));
270 270
271 UnloadExtension(last_loaded_extension_id_); 271 UnloadExtension(last_loaded_extension_id_);
272 272
273 // Make sure the page action goes away when it's unloaded. 273 // Make sure the page action goes away when it's unloaded.
274 ASSERT_TRUE(WaitForPageActionCountChangeTo(0)); 274 ASSERT_TRUE(WaitForPageActionCountChangeTo(0));
275 } 275 }
276 276
277 // Makes sure that the RSS detects RSS feed links, even when rel tag contains 277 // Makes sure that the RSS detects RSS feed links, even when rel tag contains
278 // more than just "alternate". 278 // more than just "alternate".
279 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, RSSMultiRelLink) { 279 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, RSSMultiRelLink) {
280 HTTPTestServer* server = StartHTTPServer(); 280 HTTPTestServer* server = StartHTTPServer();
281 281
282 ASSERT_TRUE(LoadExtension( 282 ASSERT_TRUE(LoadExtension(
283 test_data_dir_.AppendASCII("subscribe_page_action"))); 283 test_data_dir_.AppendASCII("subscribe_page_action")));
284 284
285 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0)); 285 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
286 286
287 // Navigate to the feed page. 287 // Navigate to the feed page.
288 GURL feed_url = server->TestServerPageW(kFeedPageMultiRel); 288 GURL feed_url = server->TestServerPage(kFeedPageMultiRel);
289 ui_test_utils::NavigateToURL(browser(), feed_url); 289 ui_test_utils::NavigateToURL(browser(), feed_url);
290 // We should now have one page action ready to go in the LocationBar. 290 // We should now have one page action ready to go in the LocationBar.
291 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 291 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
292 } 292 }
293 293
294 // Tests that tooltips of a browser action icon can be specified using UTF8. 294 // Tests that tooltips of a browser action icon can be specified using UTF8.
295 // See http://crbug.com/25349. 295 // See http://crbug.com/25349.
296 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) { 296 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) {
297 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 297 ExtensionsService* service = browser()->profile()->GetExtensionsService();
298 const size_t size_before = service->extensions()->size(); 298 const size_t size_before = service->extensions()->size();
(...skipping 19 matching lines...) Expand all
318 HTTPTestServer* server = StartHTTPServer(); 318 HTTPTestServer* server = StartHTTPServer();
319 319
320 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 320 ExtensionsService* service = browser()->profile()->GetExtensionsService();
321 const size_t size_before = service->extensions()->size(); 321 const size_t size_before = service->extensions()->size();
322 322
323 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") 323 FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
324 .AppendASCII("title_localized_pa")); 324 .AppendASCII("title_localized_pa"));
325 ASSERT_TRUE(LoadExtension(extension_path)); 325 ASSERT_TRUE(LoadExtension(extension_path));
326 326
327 // Any navigation prompts the location bar to load the page action. 327 // Any navigation prompts the location bar to load the page action.
328 GURL url = server->TestServerPageW(kLocalization); 328 GURL url = server->TestServerPage(kLocalization);
329 ui_test_utils::NavigateToURL(browser(), url); 329 ui_test_utils::NavigateToURL(browser(), url);
330 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 330 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
331 331
332 ASSERT_EQ(size_before + 1, service->extensions()->size()); 332 ASSERT_EQ(size_before + 1, service->extensions()->size());
333 Extension* extension = service->extensions()->at(size_before); 333 Extension* extension = service->extensions()->at(size_before);
334 334
335 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), 335 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(),
336 extension->description().c_str()); 336 extension->description().c_str());
337 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), 337 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(),
338 extension->name().c_str()); 338 extension->name().c_str());
339 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); 339 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents());
340 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), 340 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(),
341 extension->page_action()->GetTitle(tab_id).c_str()); 341 extension->page_action()->GetTitle(tab_id).c_str());
342 } 342 }
343 343
344 GURL GetFeedUrl(HTTPTestServer* server, const std::wstring& feed_page, 344 GURL GetFeedUrl(HTTPTestServer* server, const std::string& feed_page,
345 bool direct_url, std::string extension_id) { 345 bool direct_url, std::string extension_id) {
346 GURL feed_url = server->TestServerPageW(feed_page); 346 GURL feed_url = server->TestServerPage(feed_page);
347 if (direct_url) { 347 if (direct_url) {
348 // We navigate directly to the subscribe page for feeds where the feed 348 // We navigate directly to the subscribe page for feeds where the feed
349 // sniffing won't work, in other words, as is the case for malformed feeds. 349 // sniffing won't work, in other words, as is the case for malformed feeds.
350 return GURL(std::string(chrome::kExtensionScheme) + 350 return GURL(std::string(chrome::kExtensionScheme) +
351 chrome::kStandardSchemeSeparator + 351 chrome::kStandardSchemeSeparator +
352 extension_id + std::string(kSubscribePage) + std::string("?") + 352 extension_id + std::string(kSubscribePage) + std::string("?") +
353 feed_url.spec() + std::string("&synchronous")); 353 feed_url.spec() + std::string("&synchronous"));
354 } else { 354 } else {
355 // Navigate to the feed content (which will cause the extension to try to 355 // Navigate to the feed content (which will cause the extension to try to
356 // sniff the type and display the subscribe page in another tab. 356 // sniff the type and display the subscribe page in another tab.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 EXPECT_STREQ(expected_value.c_str(), returned_value.c_str()); 399 EXPECT_STREQ(expected_value.c_str(), returned_value.c_str());
400 return expected_value == returned_value; 400 return expected_value == returned_value;
401 } 401 }
402 402
403 // Navigates to a feed page and, if |sniff_xml_type| is set, wait for the 403 // Navigates to a feed page and, if |sniff_xml_type| is set, wait for the
404 // extension to kick in, detect the feed and redirect to a feed preview page. 404 // extension to kick in, detect the feed and redirect to a feed preview page.
405 // |sniff_xml_type| is generally set to true if the feed is sniffable and false 405 // |sniff_xml_type| is generally set to true if the feed is sniffable and false
406 // for invalid feeds. 406 // for invalid feeds.
407 void NavigateToFeedAndValidate(HTTPTestServer* server, 407 void NavigateToFeedAndValidate(HTTPTestServer* server,
408 const std::wstring& url, 408 const std::string& url,
409 Browser* browser, 409 Browser* browser,
410 bool sniff_xml_type, 410 bool sniff_xml_type,
411 const std::string& expected_feed_title, 411 const std::string& expected_feed_title,
412 const std::string& expected_item_title, 412 const std::string& expected_item_title,
413 const std::string& expected_item_desc, 413 const std::string& expected_item_desc,
414 const std::string& expected_error) { 414 const std::string& expected_error) {
415 if (sniff_xml_type) { 415 if (sniff_xml_type) {
416 // TODO(finnur): Implement this is a non-flaky way. 416 // TODO(finnur): Implement this is a non-flaky way.
417 } 417 }
418 418
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 "Not a valid feed."); 551 "Not a valid feed.");
552 } 552 }
553 553
554 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) { 554 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) {
555 HTTPTestServer* server = StartHTTPServer(); 555 HTTPTestServer* server = StartHTTPServer();
556 556
557 ASSERT_TRUE(LoadExtension( 557 ASSERT_TRUE(LoadExtension(
558 test_data_dir_.AppendASCII("subscribe_page_action"))); 558 test_data_dir_.AppendASCII("subscribe_page_action")));
559 559
560 // Try a feed that doesn't exist. 560 // Try a feed that doesn't exist.
561 NavigateToFeedAndValidate(server, L"foo.xml", browser(), false, 561 NavigateToFeedAndValidate(server, "foo.xml", browser(), false,
562 "Feed for Unknown feed name", 562 "Feed for Unknown feed name",
563 "element 'anchor_0' not found", 563 "element 'anchor_0' not found",
564 "element 'desc_0' not found", 564 "element 'desc_0' not found",
565 "Not a valid feed."); 565 "Not a valid feed.");
566 } 566 }
567 567
568 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) { 568 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) {
569 HTTPTestServer* server = StartHTTPServer(); 569 HTTPTestServer* server = StartHTTPServer();
570 570
571 ASSERT_TRUE(LoadExtension( 571 ASSERT_TRUE(LoadExtension(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 764
765 // If the options page hasn't already come up, wait for it. 765 // If the options page hasn't already come up, wait for it.
766 if (tab_strip->count() == 1) { 766 if (tab_strip->count() == 1) {
767 ui_test_utils::WaitForNewTab(browser()); 767 ui_test_utils::WaitForNewTab(browser());
768 } 768 }
769 ASSERT_EQ(2, tab_strip->count()); 769 ASSERT_EQ(2, tab_strip->count());
770 770
771 EXPECT_EQ(extension->GetResourceURL("options.html"), 771 EXPECT_EQ(extension->GetResourceURL("options.html"),
772 tab_strip->GetTabContentsAt(1)->GetURL()); 772 tab_strip->GetTabContentsAt(1)->GetURL());
773 } 773 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698