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

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

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 years 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 | Annotate | Revision Log
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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/ref_counted.h" 6 #include "base/ref_counted.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_list.h" 8 #include "chrome/browser/browser_list.h"
9 #include "chrome/browser/extensions/autoupdate_interceptor.h" 9 #include "chrome/browser/extensions/autoupdate_interceptor.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
12 #include "chrome/browser/extensions/extension_error_reporter.h" 12 #include "chrome/browser/extensions/extension_error_reporter.h"
13 #include "chrome/browser/extensions/extension_host.h" 13 #include "chrome/browser/extensions/extension_host.h"
14 #include "chrome/browser/extensions/extension_process_manager.h" 14 #include "chrome/browser/extensions/extension_process_manager.h"
15 #include "chrome/browser/extensions/extension_tabs_module.h" 15 #include "chrome/browser/extensions/extension_tabs_module.h"
16 #include "chrome/browser/extensions/extensions_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_updater.h" 17 #include "chrome/browser/extensions/extension_updater.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/renderer_host/render_view_host.h" 19 #include "chrome/browser/renderer_host/render_view_host.h"
20 #include "chrome/browser/renderer_host/site_instance.h" 20 #include "chrome/browser/renderer_host/site_instance.h"
21 #include "chrome/browser/tab_contents/tab_contents.h" 21 #include "chrome/browser/tab_contents/tab_contents.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 22 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/extensions/extension_action.h" 26 #include "chrome/common/extensions/extension_action.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 263
264 // Flaky crash on Mac debug. http://crbug.com/45079 264 // Flaky crash on Mac debug. http://crbug.com/45079
265 #if defined(OS_MACOSX) 265 #if defined(OS_MACOSX)
266 #define PageActionRefreshCrash PageActionRefreshCrash 266 #define PageActionRefreshCrash PageActionRefreshCrash
267 #endif 267 #endif
268 // Tests that we can load page actions in the Omnibox. 268 // Tests that we can load page actions in the Omnibox.
269 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { 269 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) {
270 base::TimeTicks start_time = base::TimeTicks::Now(); 270 base::TimeTicks start_time = base::TimeTicks::Now();
271 271
272 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 272 ExtensionService* service = browser()->profile()->GetExtensionService();
273 273
274 size_t size_before = service->extensions()->size(); 274 size_t size_before = service->extensions()->size();
275 275
276 FilePath base_path = test_data_dir_.AppendASCII("browsertest") 276 FilePath base_path = test_data_dir_.AppendASCII("browsertest")
277 .AppendASCII("crash_44415"); 277 .AppendASCII("crash_44415");
278 // Load extension A. 278 // Load extension A.
279 ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtA"))); 279 ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtA")));
280 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 280 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
281 ASSERT_EQ(size_before + 1, service->extensions()->size()); 281 ASSERT_EQ(size_before + 1, service->extensions()->size());
282 const Extension* extensionA = service->extensions()->at(size_before); 282 const Extension* extensionA = service->extensions()->at(size_before);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Navigate to the feed page. 331 // Navigate to the feed page.
332 GURL feed_url = test_server()->GetURL(kFeedPageMultiRel); 332 GURL feed_url = test_server()->GetURL(kFeedPageMultiRel);
333 ui_test_utils::NavigateToURL(browser(), feed_url); 333 ui_test_utils::NavigateToURL(browser(), feed_url);
334 // We should now have one page action ready to go in the LocationBar. 334 // We should now have one page action ready to go in the LocationBar.
335 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 335 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
336 } 336 }
337 337
338 // Tests that tooltips of a browser action icon can be specified using UTF8. 338 // Tests that tooltips of a browser action icon can be specified using UTF8.
339 // See http://crbug.com/25349. 339 // See http://crbug.com/25349.
340 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) { 340 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) {
341 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 341 ExtensionService* service = browser()->profile()->GetExtensionService();
342 const size_t size_before = service->extensions()->size(); 342 const size_t size_before = service->extensions()->size();
343 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") 343 FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
344 .AppendASCII("title_localized")); 344 .AppendASCII("title_localized"));
345 ASSERT_TRUE(LoadExtension(extension_path)); 345 ASSERT_TRUE(LoadExtension(extension_path));
346 346
347 ASSERT_EQ(size_before + 1, service->extensions()->size()); 347 ASSERT_EQ(size_before + 1, service->extensions()->size());
348 const Extension* extension = service->extensions()->at(size_before); 348 const Extension* extension = service->extensions()->at(size_before);
349 349
350 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(), 350 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(),
351 extension->description().c_str()); 351 extension->description().c_str());
352 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), 352 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(),
353 extension->name().c_str()); 353 extension->name().c_str());
354 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); 354 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents());
355 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), 355 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(),
356 extension->browser_action()->GetTitle(tab_id).c_str()); 356 extension->browser_action()->GetTitle(tab_id).c_str());
357 } 357 }
358 358
359 // Tests that tooltips of a page action icon can be specified using UTF8. 359 // Tests that tooltips of a page action icon can be specified using UTF8.
360 // See http://crbug.com/25349. 360 // See http://crbug.com/25349.
361 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { 361 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) {
362 ASSERT_TRUE(test_server()->Start()); 362 ASSERT_TRUE(test_server()->Start());
363 363
364 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 364 ExtensionService* service = browser()->profile()->GetExtensionService();
365 const size_t size_before = service->extensions()->size(); 365 const size_t size_before = service->extensions()->size();
366 366
367 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") 367 FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
368 .AppendASCII("title_localized_pa")); 368 .AppendASCII("title_localized_pa"));
369 ASSERT_TRUE(LoadExtension(extension_path)); 369 ASSERT_TRUE(LoadExtension(extension_path));
370 370
371 // Any navigation prompts the location bar to load the page action. 371 // Any navigation prompts the location bar to load the page action.
372 GURL url = test_server()->GetURL(kLocalization); 372 GURL url = test_server()->GetURL(kLocalization);
373 ui_test_utils::NavigateToURL(browser(), url); 373 ui_test_utils::NavigateToURL(browser(), url);
374 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 374 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 Browser* browser, 453 Browser* browser,
454 bool sniff_xml_type, 454 bool sniff_xml_type,
455 const std::string& expected_feed_title, 455 const std::string& expected_feed_title,
456 const std::string& expected_item_title, 456 const std::string& expected_item_title,
457 const std::string& expected_item_desc, 457 const std::string& expected_item_desc,
458 const std::string& expected_error) { 458 const std::string& expected_error) {
459 if (sniff_xml_type) { 459 if (sniff_xml_type) {
460 // TODO(finnur): Implement this is a non-flaky way. 460 // TODO(finnur): Implement this is a non-flaky way.
461 } 461 }
462 462
463 ExtensionsService* service = browser->profile()->GetExtensionsService(); 463 ExtensionService* service = browser->profile()->GetExtensionService();
464 const Extension* extension = service->extensions()->back(); 464 const Extension* extension = service->extensions()->back();
465 std::string id = extension->id(); 465 std::string id = extension->id();
466 466
467 // Navigate to the subscribe page directly. 467 // Navigate to the subscribe page directly.
468 ui_test_utils::NavigateToURL(browser, GetFeedUrl(server, url, true, id)); 468 ui_test_utils::NavigateToURL(browser, GetFeedUrl(server, url, true, id));
469 469
470 TabContents* tab = browser->GetSelectedTabContents(); 470 TabContents* tab = browser->GetSelectedTabContents();
471 ASSERT_TRUE(ValidatePageElement(tab, 471 ASSERT_TRUE(ValidatePageElement(tab,
472 L"", 472 L"",
473 jscript_feed_title, 473 jscript_feed_title,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 ui_test_utils::NavigateToURL(browser(), 755 ui_test_utils::NavigateToURL(browser(),
756 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); 756 net::FilePathToFileURL(extension_dir.AppendASCII("test.html")));
757 TabContents* tab = browser()->GetSelectedTabContents(); 757 TabContents* tab = browser()->GetSelectedTabContents();
758 758
759 // With no extensions, the plugin should not be loaded. 759 // With no extensions, the plugin should not be loaded.
760 bool result = false; 760 bool result = false;
761 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 761 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
762 tab->render_view_host(), L"", L"testPluginWorks()", &result)); 762 tab->render_view_host(), L"", L"testPluginWorks()", &result));
763 EXPECT_FALSE(result); 763 EXPECT_FALSE(result);
764 764
765 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 765 ExtensionService* service = browser()->profile()->GetExtensionService();
766 const size_t size_before = service->extensions()->size(); 766 const size_t size_before = service->extensions()->size();
767 ASSERT_TRUE(LoadExtension(extension_dir)); 767 ASSERT_TRUE(LoadExtension(extension_dir));
768 EXPECT_EQ(size_before + 1, service->extensions()->size()); 768 EXPECT_EQ(size_before + 1, service->extensions()->size());
769 // Now the plugin should be in the cache, but we have to reload the page for 769 // Now the plugin should be in the cache, but we have to reload the page for
770 // it to work. 770 // it to work.
771 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 771 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
772 tab->render_view_host(), L"", L"testPluginWorks()", &result)); 772 tab->render_view_host(), L"", L"testPluginWorks()", &result));
773 EXPECT_FALSE(result); 773 EXPECT_FALSE(result);
774 browser()->Reload(CURRENT_TAB); 774 browser()->Reload(CURRENT_TAB);
775 ui_test_utils::WaitForNavigationInCurrentTab(browser()); 775 ui_test_utils::WaitForNavigationInCurrentTab(browser());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 L" button.click();" 807 L" button.click();"
808 L"})();"; 808 L"})();";
809 809
810 // Test that an extension with an options page makes an 'Options' button appear 810 // Test that an extension with an options page makes an 'Options' button appear
811 // on chrome://extensions, and that clicking the button opens a new tab with the 811 // on chrome://extensions, and that clicking the button opens a new tab with the
812 // extension's options page. 812 // extension's options page.
813 // Disabled. See http://crbug.com/26948 for details. 813 // Disabled. See http://crbug.com/26948 for details.
814 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { 814 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) {
815 // Install an extension with an options page. 815 // Install an extension with an options page.
816 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1)); 816 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1));
817 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 817 ExtensionService* service = browser()->profile()->GetExtensionService();
818 const ExtensionList* extensions = service->extensions(); 818 const ExtensionList* extensions = service->extensions();
819 ASSERT_EQ(1u, extensions->size()); 819 ASSERT_EQ(1u, extensions->size());
820 const Extension* extension = extensions->at(0); 820 const Extension* extension = extensions->at(0);
821 821
822 // Go to the chrome://extensions page and click the Options button. 822 // Go to the chrome://extensions page and click the Options button.
823 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); 823 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL));
824 TabStripModel* tab_strip = browser()->tabstrip_model(); 824 TabStripModel* tab_strip = browser()->tabstrip_model();
825 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 825 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
826 browser()->GetSelectedTabContents()->render_view_host(), L"", 826 browser()->GetSelectedTabContents()->render_view_host(), L"",
827 jscript_click_option_button)); 827 jscript_click_option_button));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 L" window.chrome.app.isInstalled = false;" 897 L" window.chrome.app.isInstalled = false;"
898 L" return 'BAD: Should have thrown by now...';" 898 L" return 'BAD: Should have thrown by now...';"
899 L" } catch (e) {" 899 L" } catch (e) {"
900 L" return 'GOOD: Saw expected error.';" 900 L" return 'GOOD: Saw expected error.';"
901 L" }" 901 L" }"
902 L" }()" 902 L" }()"
903 L");", 903 L");",
904 &result)); 904 &result));
905 EXPECT_EQ("GOOD: Saw expected error.", result); 905 EXPECT_EQ("GOOD: Saw expected error.", result);
906 } 906 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_context_menu_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698