| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "chrome/browser/extensions/component_loader.h" | 8 #include "chrome/browser/extensions/component_loader.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" | 13 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 16 #include "extensions/test/result_catcher.h" |
| 16 #include "grit/browser_resources.h" | 17 #include "grit/browser_resources.h" |
| 17 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 18 | 19 |
| 19 class PDFExtensionTest : public ExtensionApiTest { | 20 class PDFExtensionTest : public ExtensionApiTest { |
| 20 public: | 21 public: |
| 21 virtual ~PDFExtensionTest() {} | 22 virtual ~PDFExtensionTest() {} |
| 22 | 23 |
| 23 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 24 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 24 ExtensionApiTest::SetUpCommandLine(command_line); | 25 ExtensionApiTest::SetUpCommandLine(command_line); |
| 25 command_line->AppendSwitch(switches::kOutOfProcessPdf); | 26 command_line->AppendSwitch(switches::kOutOfProcessPdf); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 ExtensionService* service = extensions::ExtensionSystem::Get( | 49 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 49 profile())->extension_service(); | 50 profile())->extension_service(); |
| 50 service->component_loader()->Add(IDR_PDF_MANIFEST, | 51 service->component_loader()->Add(IDR_PDF_MANIFEST, |
| 51 base::FilePath(FILE_PATH_LITERAL("pdf"))); | 52 base::FilePath(FILE_PATH_LITERAL("pdf"))); |
| 52 const extensions::Extension* extension = | 53 const extensions::Extension* extension = |
| 53 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); | 54 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); |
| 54 ASSERT_TRUE(extension); | 55 ASSERT_TRUE(extension); |
| 55 ASSERT_TRUE(MimeTypesHandler::GetHandler( | 56 ASSERT_TRUE(MimeTypesHandler::GetHandler( |
| 56 extension)->CanHandleMIMEType("application/pdf")); | 57 extension)->CanHandleMIMEType("application/pdf")); |
| 57 | 58 |
| 58 ResultCatcher catcher; | 59 extensions::ResultCatcher catcher; |
| 59 | 60 |
| 60 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); | 61 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); |
| 61 GURL extension_url( | 62 GURL extension_url( |
| 62 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + | 63 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + |
| 63 url.spec()); | 64 url.spec()); |
| 64 ui_test_utils::NavigateToURL(browser(), extension_url); | 65 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 65 content::WebContents* contents = | 66 content::WebContents* contents = |
| 66 browser()->tab_strip_model()->GetActiveWebContents(); | 67 browser()->tab_strip_model()->GetActiveWebContents(); |
| 67 content::WaitForLoadStop(contents); | 68 content::WaitForLoadStop(contents); |
| 68 | 69 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 RunTestsInFile("basic_test.js", false); | 86 RunTestsInFile("basic_test.js", false); |
| 86 } | 87 } |
| 87 | 88 |
| 88 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { | 89 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { |
| 89 RunTestsInFile("basic_plugin_test.js", true); | 90 RunTestsInFile("basic_plugin_test.js", true); |
| 90 } | 91 } |
| 91 | 92 |
| 92 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { | 93 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { |
| 93 RunTestsInFile("viewport_test.js", false); | 94 RunTestsInFile("viewport_test.js", false); |
| 94 } | 95 } |
| OLD | NEW |