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

Side by Side Diff: chrome/test/data/pdf/pdf_extension_test.cc

Issue 290803007: Re-enable PDFExtensionTest.BasicPlugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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
« no previous file with comments | « chrome/test/data/pdf/basic_plugin_test.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/base_paths.h"
6 #include "base/file_util.h"
7 #include "base/path_service.h"
8 #include "chrome/browser/extensions/component_loader.h"
9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "grit/browser_resources.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h"
18
19 class PDFExtensionTest : public ExtensionApiTest {
20 public:
21 virtual ~PDFExtensionTest() {}
22
23 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
24 ExtensionApiTest::SetUpCommandLine(command_line);
25 command_line->AppendSwitch(switches::kOutOfProcessPdf);
26 }
27
28 virtual void SetUpOnMainThread() OVERRIDE {
29 ExtensionApiTest::SetUpOnMainThread();
30 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
31 }
32
33
34 virtual void CleanUpOnMainThread() OVERRIDE {
35 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
36 ExtensionApiTest::CleanUpOnMainThread();
37 }
38
39 void RunTestsInFile(std::string filename, bool requiresPlugin) {
40 #if !defined(GOOGLE_CHROME_BUILD)
41 base::FilePath pdf_plugin_src;
42 PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src);
43 pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf");
44 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) {
45 LOG(WARNING) << "Not running " << filename <<
46 " because it requires the PDF plugin which is not available.";
47 return;
48 }
49 #endif
50 ExtensionService* service = extensions::ExtensionSystem::Get(
51 profile())->extension_service();
52 service->component_loader()->Add(IDR_PDF_MANIFEST,
53 base::FilePath(FILE_PATH_LITERAL("pdf")));
54 const extensions::Extension* extension =
55 service->extensions()->GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai");
56 ASSERT_TRUE(extension);
57 ASSERT_TRUE(MimeTypesHandler::GetHandler(
58 extension)->CanHandleMIMEType("application/pdf"));
59
60 ResultCatcher catcher;
61
62 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf"));
63 GURL extension_url(
64 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" +
65 url.spec());
66 ui_test_utils::NavigateToURL(browser(), extension_url);
67 content::WebContents* contents =
68 browser()->tab_strip_model()->GetActiveWebContents();
69 content::WaitForLoadStop(contents);
70
71 base::FilePath test_data_dir;
72 PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir);
73 test_data_dir = test_data_dir.Append(
74 FILE_PATH_LITERAL("chrome/test/data/pdf"));
75 test_data_dir = test_data_dir.AppendASCII(filename);
76
77 std::string test_js;
78 ASSERT_TRUE(base::ReadFileToString(test_data_dir, &test_js));
79 ASSERT_TRUE(content::ExecuteScript(contents, test_js));
80
81 if (!catcher.GetNextResult())
82 FAIL() << catcher.message();
83 }
84 };
85
86 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) {
87 RunTestsInFile("basic_test.js", false);
88 }
89
90 // TODO(raymes): investigate why this started failing after PDF plugin became
91 // open source.
92 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_BasicPlugin) {
93 RunTestsInFile("basic_plugin_test.js", true);
94 }
95
96 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) {
97 RunTestsInFile("viewport_test.js", false);
98 }
OLDNEW
« no previous file with comments | « chrome/test/data/pdf/basic_plugin_test.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698