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/browser/extension_registry.h" |
16 #include "extensions/test/result_catcher.h" | 17 #include "extensions/test/result_catcher.h" |
17 #include "grit/browser_resources.h" | 18 #include "grit/browser_resources.h" |
18 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
19 | 20 |
20 class PDFExtensionTest : public ExtensionApiTest { | 21 class PDFExtensionTest : public ExtensionApiTest { |
21 public: | 22 public: |
22 virtual ~PDFExtensionTest() {} | 23 virtual ~PDFExtensionTest() {} |
23 | 24 |
24 virtual void SetUpCommandLine(CommandLine* command_line) override { | 25 virtual void SetUpCommandLine(CommandLine* command_line) override { |
25 ExtensionApiTest::SetUpCommandLine(command_line); | 26 ExtensionApiTest::SetUpCommandLine(command_line); |
(...skipping 18 matching lines...) Expand all Loading... |
44 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) { | 45 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) { |
45 LOG(WARNING) << "Not running " << filename << | 46 LOG(WARNING) << "Not running " << filename << |
46 " because it requires the PDF plugin which is not available."; | 47 " because it requires the PDF plugin which is not available."; |
47 return; | 48 return; |
48 } | 49 } |
49 ExtensionService* service = extensions::ExtensionSystem::Get( | 50 ExtensionService* service = extensions::ExtensionSystem::Get( |
50 profile())->extension_service(); | 51 profile())->extension_service(); |
51 service->component_loader()->Add(IDR_PDF_MANIFEST, | 52 service->component_loader()->Add(IDR_PDF_MANIFEST, |
52 base::FilePath(FILE_PATH_LITERAL("pdf"))); | 53 base::FilePath(FILE_PATH_LITERAL("pdf"))); |
53 const extensions::Extension* extension = | 54 const extensions::Extension* extension = |
54 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); | 55 extensions::ExtensionRegistry::Get(profile()) |
| 56 ->enabled_extensions() |
| 57 .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); |
55 ASSERT_TRUE(extension); | 58 ASSERT_TRUE(extension); |
56 ASSERT_TRUE(MimeTypesHandler::GetHandler( | 59 ASSERT_TRUE(MimeTypesHandler::GetHandler( |
57 extension)->CanHandleMIMEType("application/pdf")); | 60 extension)->CanHandleMIMEType("application/pdf")); |
58 | 61 |
59 extensions::ResultCatcher catcher; | 62 extensions::ResultCatcher catcher; |
60 | 63 |
61 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); | 64 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); |
62 GURL extension_url( | 65 GURL extension_url( |
63 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + | 66 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + |
64 url.spec()); | 67 url.spec()); |
(...skipping 21 matching lines...) Expand all Loading... |
86 RunTestsInFile("basic_test.js", false); | 89 RunTestsInFile("basic_test.js", false); |
87 } | 90 } |
88 | 91 |
89 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { | 92 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { |
90 RunTestsInFile("basic_plugin_test.js", true); | 93 RunTestsInFile("basic_plugin_test.js", true); |
91 } | 94 } |
92 | 95 |
93 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { | 96 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { |
94 RunTestsInFile("viewport_test.js", false); | 97 RunTestsInFile("viewport_test.js", false); |
95 } | 98 } |
OLD | NEW |