| 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/file_util.h" | 6 #include "base/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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 30 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 virtual void CleanUpOnMainThread() OVERRIDE { | 34 virtual void CleanUpOnMainThread() OVERRIDE { |
| 35 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 35 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
| 36 ExtensionApiTest::CleanUpOnMainThread(); | 36 ExtensionApiTest::CleanUpOnMainThread(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void RunTestsInFile(std::string filename, bool requiresPlugin) { | 39 void RunTestsInFile(std::string filename, bool requiresPlugin) { |
| 40 #if !defined(GOOGLE_CHROME_BUILD) | |
| 41 base::FilePath pdf_plugin_src; | 40 base::FilePath pdf_plugin_src; |
| 42 PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src); | 41 PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src); |
| 43 pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf"); | 42 pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf"); |
| 44 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) { | 43 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) { |
| 45 LOG(WARNING) << "Not running " << filename << | 44 LOG(WARNING) << "Not running " << filename << |
| 46 " because it requires the PDF plugin which is not available."; | 45 " because it requires the PDF plugin which is not available."; |
| 47 return; | 46 return; |
| 48 } | 47 } |
| 49 #endif | |
| 50 ExtensionService* service = extensions::ExtensionSystem::Get( | 48 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 51 profile())->extension_service(); | 49 profile())->extension_service(); |
| 52 service->component_loader()->Add(IDR_PDF_MANIFEST, | 50 service->component_loader()->Add(IDR_PDF_MANIFEST, |
| 53 base::FilePath(FILE_PATH_LITERAL("pdf"))); | 51 base::FilePath(FILE_PATH_LITERAL("pdf"))); |
| 54 const extensions::Extension* extension = | 52 const extensions::Extension* extension = |
| 55 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); | 53 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); |
| 56 ASSERT_TRUE(extension); | 54 ASSERT_TRUE(extension); |
| 57 ASSERT_TRUE(MimeTypesHandler::GetHandler( | 55 ASSERT_TRUE(MimeTypesHandler::GetHandler( |
| 58 extension)->CanHandleMIMEType("application/pdf")); | 56 extension)->CanHandleMIMEType("application/pdf")); |
| 59 | 57 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 | 78 |
| 81 if (!catcher.GetNextResult()) | 79 if (!catcher.GetNextResult()) |
| 82 FAIL() << catcher.message(); | 80 FAIL() << catcher.message(); |
| 83 } | 81 } |
| 84 }; | 82 }; |
| 85 | 83 |
| 86 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) { | 84 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) { |
| 87 RunTestsInFile("basic_test.js", false); | 85 RunTestsInFile("basic_test.js", false); |
| 88 } | 86 } |
| 89 | 87 |
| 90 // TODO(raymes): investigate why this started failing after PDF plugin became | 88 // TODO(raymes): This fails with component builds on linux because the plugin |
| 91 // open source. | 89 // plugin crashes due to something related to how the plugin DLL is |
| 92 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_BasicPlugin) { | 90 // compiled/linked. crbug.com/386436. |
| 91 #if defined(LINUX) && defined(COMPONENT_BUILD) |
| 92 #define MAYBE_BasicPlugin DISABLED_BasicPlugin |
| 93 #else |
| 94 #define MAYBE_BasicPlugin BasicPlugin |
| 95 #endif |
| 96 |
| 97 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_BasicPlugin) { |
| 93 RunTestsInFile("basic_plugin_test.js", true); | 98 RunTestsInFile("basic_plugin_test.js", true); |
| 94 } | 99 } |
| 95 | 100 |
| 96 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { | 101 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { |
| 97 RunTestsInFile("viewport_test.js", false); | 102 RunTestsInFile("viewport_test.js", false); |
| 98 } | 103 } |
| OLD | NEW |