diff options
author | raymes <raymes@chromium.org> | 2015-04-30 22:57:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-01 05:58:06 +0000 |
commit | 6b282cd08ee3e025fddb66bf13ed793af1d3a2fe (patch) | |
tree | 4ee5e2dbbef85db83c4f3b17b8d2a657e9597884 /chrome/browser/pdf | |
parent | 54ad9a3904715454c2ad8981cfdc65f35d786065 (diff) | |
download | chromium_src-6b282cd08ee3e025fddb66bf13ed793af1d3a2fe.zip chromium_src-6b282cd08ee3e025fddb66bf13ed793af1d3a2fe.tar.gz chromium_src-6b282cd08ee3e025fddb66bf13ed793af1d3a2fe.tar.bz2 |
Make the PDFExtensionTests run from inside the MimeHandlerGuest
This ensures that the tests run inside the MimeHandlerGuest which more closely
matches the production environment.
BUG=436444
Review URL: https://codereview.chromium.org/1115103002
Cr-Commit-Position: refs/heads/master@{#327884}
Diffstat (limited to 'chrome/browser/pdf')
-rw-r--r-- | chrome/browser/pdf/pdf_extension_test.cc | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc index 002363e..abf467c 100644 --- a/chrome/browser/pdf/pdf_extension_test.cc +++ b/chrome/browser/pdf/pdf_extension_test.cc @@ -12,6 +12,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/browser_plugin_guest_manager.h" #include "content/public/browser/plugin_service.h" #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_registry.h" @@ -40,33 +41,23 @@ class PDFExtensionTest : public ExtensionApiTest { } void RunTestsInFile(std::string filename, std::string pdf_filename) { - ExtensionService* service = extensions::ExtensionSystem::Get( - profile())->extension_service(); - service->component_loader()->Add(IDR_PDF_MANIFEST, - base::FilePath(FILE_PATH_LITERAL("pdf"))); - const extensions::Extension* extension = - extensions::ExtensionRegistry::Get(profile()) - ->enabled_extensions() - .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); - ASSERT_TRUE(extension); - ASSERT_TRUE(MimeTypesHandler::GetHandler( - extension)->CanHandleMIMEType("application/pdf")); - extensions::ResultCatcher catcher; GURL url(embedded_test_server()->GetURL("/pdf/" + pdf_filename)); - GURL extension_url( - "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + - url.spec()); - ui_test_utils::NavigateToURL(browser(), extension_url); + ui_test_utils::NavigateToURL(browser(), url); + content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - content::WaitForLoadStop(contents); + content::BrowserPluginGuestManager* guest_manager = + contents->GetBrowserContext()->GetGuestManager(); + content::WebContents* guest_contents = + guest_manager->GetFullPageGuest(contents); + ASSERT_TRUE(guest_contents); + EXPECT_TRUE(content::WaitForLoadStop(guest_contents)); base::FilePath test_data_dir; - PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir); - test_data_dir = test_data_dir.Append( - FILE_PATH_LITERAL("chrome/test/data/pdf")); + PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); + test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf")); base::FilePath test_util_path = test_data_dir.AppendASCII("test_util.js"); std::string test_util_js; ASSERT_TRUE(base::ReadFileToString(test_util_path, &test_util_js)); @@ -76,7 +67,7 @@ class PDFExtensionTest : public ExtensionApiTest { ASSERT_TRUE(base::ReadFileToString(test_file_path, &test_js)); test_util_js.append(test_js); - ASSERT_TRUE(content::ExecuteScript(contents, test_util_js)); + ASSERT_TRUE(content::ExecuteScript(guest_contents, test_util_js)); if (!catcher.GetNextResult()) FAIL() << catcher.message(); |