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

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

Issue 840493002: Introduce new test for bookmark loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks-minimal
Patch Set: Remove newline in argument list. 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 22 matching lines...) Expand all
33 ExtensionApiTest::SetUpOnMainThread(); 33 ExtensionApiTest::SetUpOnMainThread();
34 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 34 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
35 } 35 }
36 36
37 37
38 virtual void TearDownOnMainThread() override { 38 virtual void TearDownOnMainThread() override {
39 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); 39 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
40 ExtensionApiTest::TearDownOnMainThread(); 40 ExtensionApiTest::TearDownOnMainThread();
41 } 41 }
42 42
43 void RunTestsInFile(std::string filename) { 43 void RunTestsInFile(std::string filename, std::string pdf_filename) {
44 base::FilePath pdf_path; 44 base::FilePath pdf_path;
45 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path)); 45 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path));
46 ASSERT_TRUE( 46 ASSERT_TRUE(
47 content::PluginService::GetInstance()->GetRegisteredPpapiPluginInfo( 47 content::PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(
48 pdf_path)); 48 pdf_path));
49 ExtensionService* service = extensions::ExtensionSystem::Get( 49 ExtensionService* service = extensions::ExtensionSystem::Get(
50 profile())->extension_service(); 50 profile())->extension_service();
51 service->component_loader()->Add(IDR_PDF_MANIFEST, 51 service->component_loader()->Add(IDR_PDF_MANIFEST,
52 base::FilePath(FILE_PATH_LITERAL("pdf"))); 52 base::FilePath(FILE_PATH_LITERAL("pdf")));
53 const extensions::Extension* extension = 53 const extensions::Extension* extension =
54 extensions::ExtensionRegistry::Get(profile()) 54 extensions::ExtensionRegistry::Get(profile())
55 ->enabled_extensions() 55 ->enabled_extensions()
56 .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai"); 56 .GetByID("mhjfbmdgcfjbbpaeojofohoefgiehjai");
57 ASSERT_TRUE(extension); 57 ASSERT_TRUE(extension);
58 ASSERT_TRUE(MimeTypesHandler::GetHandler( 58 ASSERT_TRUE(MimeTypesHandler::GetHandler(
59 extension)->CanHandleMIMEType("application/pdf")); 59 extension)->CanHandleMIMEType("application/pdf"));
60 60
61 extensions::ResultCatcher catcher; 61 extensions::ResultCatcher catcher;
62 62
63 GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); 63 GURL url(embedded_test_server()->GetURL("/pdf/" + pdf_filename));
64 GURL extension_url( 64 GURL extension_url(
65 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" + 65 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" +
66 url.spec()); 66 url.spec());
67 ui_test_utils::NavigateToURL(browser(), extension_url); 67 ui_test_utils::NavigateToURL(browser(), extension_url);
68 content::WebContents* contents = 68 content::WebContents* contents =
69 browser()->tab_strip_model()->GetActiveWebContents(); 69 browser()->tab_strip_model()->GetActiveWebContents();
70 content::WaitForLoadStop(contents); 70 content::WaitForLoadStop(contents);
71 71
72 base::FilePath test_data_dir; 72 base::FilePath test_data_dir;
73 PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir); 73 PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir);
74 test_data_dir = test_data_dir.Append( 74 test_data_dir = test_data_dir.Append(
75 FILE_PATH_LITERAL("chrome/test/data/pdf")); 75 FILE_PATH_LITERAL("chrome/test/data/pdf"));
76 test_data_dir = test_data_dir.AppendASCII(filename); 76 test_data_dir = test_data_dir.AppendASCII(filename);
77 77
78 std::string test_js; 78 std::string test_js;
79 ASSERT_TRUE(base::ReadFileToString(test_data_dir, &test_js)); 79 ASSERT_TRUE(base::ReadFileToString(test_data_dir, &test_js));
80 ASSERT_TRUE(content::ExecuteScript(contents, test_js)); 80 ASSERT_TRUE(content::ExecuteScript(contents, test_js));
81 81
82 if (!catcher.GetNextResult()) 82 if (!catcher.GetNextResult())
83 FAIL() << catcher.message(); 83 FAIL() << catcher.message();
84 } 84 }
85 }; 85 };
86 86
87 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) { 87 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) {
88 RunTestsInFile("basic_test.js"); 88 RunTestsInFile("basic_test.js", "test.pdf");
89 } 89 }
90 90
91 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) { 91 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BasicPlugin) {
92 RunTestsInFile("basic_plugin_test.js"); 92 RunTestsInFile("basic_plugin_test.js", "test.pdf");
93 } 93 }
94 94
95 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) { 95 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Viewport) {
96 RunTestsInFile("viewport_test.js"); 96 RunTestsInFile("viewport_test.js", "test.pdf");
97 } 97 }
98
99 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Bookmark) {
100 RunTestsInFile("bookmarks_test.js", "test-bookmarks.pdf");
101 }
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