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

Side by Side Diff: chrome/browser/resources/pdf/pdf_extension_test.cc

Issue 857863002: Revert of Introduce new test for bookmark loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks-minimal
Patch Set: Created 5 years, 11 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
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/test/data/pdf/bookmarks_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
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"
(...skipping 20 matching lines...) Expand all
31 ExtensionApiTest::SetUpOnMainThread(); 31 ExtensionApiTest::SetUpOnMainThread();
32 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 32 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
33 } 33 }
34 34
35 35
36 virtual void TearDownOnMainThread() override { 36 virtual void TearDownOnMainThread() override {
37 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); 37 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
38 ExtensionApiTest::TearDownOnMainThread(); 38 ExtensionApiTest::TearDownOnMainThread();
39 } 39 }
40 40
41 void RunTestsInFile(std::string filename, 41 void RunTestsInFile(std::string filename, bool requiresPlugin) {
42 std::string pdf_filename) {
43 base::FilePath pdf_plugin_src; 42 base::FilePath pdf_plugin_src;
44 PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src); 43 PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src);
45 pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf"); 44 pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf");
46 if (!base::DirectoryExists(pdf_plugin_src)) { 45 if (requiresPlugin && !base::DirectoryExists(pdf_plugin_src)) {
47 LOG(WARNING) << "Not running " << filename << 46 LOG(WARNING) << "Not running " << filename <<
48 " because it requires the PDF plugin which is not available."; 47 " because it requires the PDF plugin which is not available.";
49 return; 48 return;
50 } 49 }
51 ExtensionService* service = extensions::ExtensionSystem::Get( 50 ExtensionService* service = extensions::ExtensionSystem::Get(
52 profile())->extension_service(); 51 profile())->extension_service();
53 service->component_loader()->Add(IDR_PDF_MANIFEST, 52 service->component_loader()->Add(IDR_PDF_MANIFEST,
54 base::FilePath(FILE_PATH_LITERAL("pdf"))); 53 base::FilePath(FILE_PATH_LITERAL("pdf")));
55 const extensions::Extension* extension = 54 const extensions::Extension* extension =
56 extensions::ExtensionRegistry::Get(profile()) 55 extensions::ExtensionRegistry::Get(profile())
57 ->enabled_extensions() 56 ->enabled_extensions()
58 .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); 57 .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai");
59 ASSERT_TRUE(extension); 58 ASSERT_TRUE(extension);
60 ASSERT_TRUE(MimeTypesHandler::GetHandler( 59 ASSERT_TRUE(MimeTypesHandler::GetHandler(
61 extension)->CanHandleMIMEType("application/pdf")); 60 extension)->CanHandleMIMEType("application/pdf"));
62 61
63 extensions::ResultCatcher catcher; 62 extensions::ResultCatcher catcher;
64 63
65 GURL url(embedded_test_server()->GetURL("/pdf/" + pdf_filename)); 64 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf"));
66 GURL extension_url( 65 GURL extension_url(
67 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + 66 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" +
68 url.spec()); 67 url.spec());
69 ui_test_utils::NavigateToURL(browser(), extension_url); 68 ui_test_utils::NavigateToURL(browser(), extension_url);
70 content::WebContents* contents = 69 content::WebContents* contents =
71 browser()->tab_strip_model()->GetActiveWebContents(); 70 browser()->tab_strip_model()->GetActiveWebContents();
72 content::WaitForLoadStop(contents); 71 content::WaitForLoadStop(contents);
73 72
74 base::FilePath test_data_dir; 73 base::FilePath test_data_dir;
75 PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir); 74 PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir);
76 test_data_dir = test_data_dir.Append( 75 test_data_dir = test_data_dir.Append(
77 FILE_PATH_LITERAL("chrome/test/data/pdf")); 76 FILE_PATH_LITERAL("chrome/test/data/pdf"));
78 test_data_dir = test_data_dir.AppendASCII(filename); 77 test_data_dir = test_data_dir.AppendASCII(filename);
79 78
80 std::string test_js; 79 std::string test_js;
81 ASSERT_TRUE(base::ReadFileToString(test_data_dir, &test_js)); 80 ASSERT_TRUE(base::ReadFileToString(test_data_dir, &test_js));
82 ASSERT_TRUE(content::ExecuteScript(contents, test_js)); 81 ASSERT_TRUE(content::ExecuteScript(contents, test_js));
83 82
84 if (!catcher.GetNextResult()) 83 if (!catcher.GetNextResult())
85 FAIL() << catcher.message(); 84 FAIL() << catcher.message();
86 } 85 }
87 }; 86 };
88 87
89 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) { 88 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) {
90 RunTestsInFile("basic_test.js", "test.pdf"); 89 RunTestsInFile("basic_test.js", false);
91 } 90 }
92 91
93 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { 92 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) {
94 RunTestsInFile("basic_plugin_test.js", "test.pdf"); 93 RunTestsInFile("basic_plugin_test.js", true);
95 } 94 }
96 95
97 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { 96 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) {
98 RunTestsInFile("viewport_test.js", "test.pdf"); 97 RunTestsInFile("viewport_test.js", false);
99 } 98 }
100
101 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Bookmark) {
102 RunTestsInFile("bookmarks_test.js", "test-bookmarks.pdf");
103 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/test/data/pdf/bookmarks_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698