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

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

Issue 2949883006: PDFExtensionTest: Stop using chrome:// URL to load mock-interactions.js (Closed)
Patch Set: Add dependency Created 3 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
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 GURL url(embedded_test_server()->GetURL("/pdf/" + pdf_filename)); 136 GURL url(embedded_test_server()->GetURL("/pdf/" + pdf_filename));
137 137
138 // It should be good enough to just navigate to the URL. But loading up the 138 // It should be good enough to just navigate to the URL. But loading up the
139 // BrowserPluginGuest seems to happen asynchronously as there was flakiness 139 // BrowserPluginGuest seems to happen asynchronously as there was flakiness
140 // being seen due to the BrowserPluginGuest not being available yet (see 140 // being seen due to the BrowserPluginGuest not being available yet (see
141 // crbug.com/498077). So instead use |LoadPdf| which ensures that the PDF is 141 // crbug.com/498077). So instead use |LoadPdf| which ensures that the PDF is
142 // loaded before continuing. 142 // loaded before continuing.
143 WebContents* guest_contents = LoadPdfGetGuestContents(url); 143 WebContents* guest_contents = LoadPdfGetGuestContents(url);
144 ASSERT_TRUE(guest_contents); 144 ASSERT_TRUE(guest_contents);
145 std::string test_util_js; 145 std::string test_util_js;
146 std::string mock_interactions_js;
146 147
147 { 148 {
148 base::ThreadRestrictions::ScopedAllowIO allow_io; 149 base::ThreadRestrictions::ScopedAllowIO allow_io;
149 base::FilePath test_data_dir; 150 base::FilePath test_data_dir;
150 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 151 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
151 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf")); 152 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf"));
152 base::FilePath test_util_path = test_data_dir.AppendASCII("test_util.js"); 153 base::FilePath test_util_path = test_data_dir.AppendASCII("test_util.js");
153 ASSERT_TRUE(base::ReadFileToString(test_util_path, &test_util_js)); 154 ASSERT_TRUE(base::ReadFileToString(test_util_path, &test_util_js));
154 155
156 base::FilePath source_root_dir;
157 PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir);
158 base::FilePath mock_interactions_path = source_root_dir.Append(
159 FILE_PATH_LITERAL("third_party/polymer/v1_0/components-chromium/"
Lei Zhang 2017/06/24 00:13:46 Is it possible to use IDR_POLYMER_1_0_IRON_TEST_HE
dpapad 2017/06/24 00:40:53 This would defeat the purpose of this CL which is
Lei Zhang 2017/06/24 00:47:59 What about moving it to browser_tests.pak? i.e. mo
dpapad 2017/06/24 01:07:38 I can explore that if preferable, but at first gla
160 "iron-test-helpers/mock-interactions.js"));
161 ASSERT_TRUE(base::ReadFileToString(mock_interactions_path,
162 &mock_interactions_js));
163 test_util_js.append(mock_interactions_js);
164
155 base::FilePath test_file_path = test_data_dir.AppendASCII(filename); 165 base::FilePath test_file_path = test_data_dir.AppendASCII(filename);
156 std::string test_js; 166 std::string test_js;
157 ASSERT_TRUE(base::ReadFileToString(test_file_path, &test_js)); 167 ASSERT_TRUE(base::ReadFileToString(test_file_path, &test_js));
158 168
159 test_util_js.append(test_js); 169 test_util_js.append(test_js);
160 } 170 }
161 171
162 ASSERT_TRUE(content::ExecuteScript(guest_contents, test_util_js)); 172 ASSERT_TRUE(content::ExecuteScript(guest_contents, test_util_js));
163 173
164 if (!catcher.GetNextResult()) 174 if (!catcher.GetNextResult())
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenFromFTP) { 1031 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenFromFTP) {
1022 net::SpawnedTestServer ftp_server( 1032 net::SpawnedTestServer ftp_server(
1023 net::SpawnedTestServer::TYPE_FTP, net::SpawnedTestServer::kLocalhost, 1033 net::SpawnedTestServer::TYPE_FTP, net::SpawnedTestServer::kLocalhost,
1024 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/pdf"))); 1034 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/pdf")));
1025 ASSERT_TRUE(ftp_server.Start()); 1035 ASSERT_TRUE(ftp_server.Start());
1026 1036
1027 GURL url(ftp_server.GetURL("/test.pdf")); 1037 GURL url(ftp_server.GetURL("/test.pdf"));
1028 ASSERT_TRUE(LoadPdf(url)); 1038 ASSERT_TRUE(LoadPdf(url));
1029 EXPECT_EQ(base::ASCIIToUTF16("test.pdf"), GetActiveWebContents()->GetTitle()); 1039 EXPECT_EQ(base::ASCIIToUTF16("test.pdf"), GetActiveWebContents()->GetTitle());
1030 } 1040 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698