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

Side by Side Diff: chrome/browser/ui/pdf/pdf_browsertest.cc

Issue 120303004: Compile pdf_browsertest.cc in non-official builds too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
25 #include "net/test/embedded_test_server/embedded_test_server.h" 25 #include "net/test/embedded_test_server/embedded_test_server.h"
26 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
27 #include "ui/base/clipboard/clipboard.h" 27 #include "ui/base/clipboard/clipboard.h"
28 #include "ui/gfx/codec/png_codec.h" 28 #include "ui/gfx/codec/png_codec.h"
29 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
30 30
31 using content::NavigationController; 31 using content::NavigationController;
32 using content::WebContents; 32 using content::WebContents;
33 33
34 // Note: All tests in here require the internal PDF plugin, so they're disabled
35 // in non-official builds. We still compile them though, to prevent bitrot.
36
34 namespace { 37 namespace {
35 38
36 // Include things like browser frame and scrollbar and make sure we're bigger 39 // Include things like browser frame and scrollbar and make sure we're bigger
37 // than the test pdf document. 40 // than the test pdf document.
38 static const int kBrowserWidth = 1000; 41 static const int kBrowserWidth = 1000;
39 static const int kBrowserHeight = 600; 42 static const int kBrowserHeight = 600;
40 43
41 class PDFBrowserTest : public InProcessBrowserTest, 44 class PDFBrowserTest : public InProcessBrowserTest,
42 public testing::WithParamInterface<int>, 45 public testing::WithParamInterface<int>,
43 public content::NotificationObserver { 46 public content::NotificationObserver {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // The filename of the bitmap to compare the snapshot to. 208 // The filename of the bitmap to compare the snapshot to.
206 std::string expected_filename_; 209 std::string expected_filename_;
207 // If the snapshot is different, holds the location where it's saved. 210 // If the snapshot is different, holds the location where it's saved.
208 base::FilePath snapshot_filename_; 211 base::FilePath snapshot_filename_;
209 // How many times we've seen chrome::LOAD_STOP. 212 // How many times we've seen chrome::LOAD_STOP.
210 int load_stop_notification_count_; 213 int load_stop_notification_count_;
211 214
212 net::test_server::EmbeddedTestServer pdf_test_server_; 215 net::test_server::EmbeddedTestServer pdf_test_server_;
213 }; 216 };
214 217
215 #if defined(OS_CHROMEOS) 218 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
216 // TODO(sanjeevr): http://crbug.com/79837 219 // TODO(sanjeevr): http://crbug.com/79837
Lei Zhang 2014/01/07 19:58:37 Would you mind changing the TODO to me since Sanje
Bernhard Bauer 2014/01/08 09:33:24 Done.
217 #define MAYBE_Basic DISABLED_Basic 220 #define MAYBE_Basic DISABLED_Basic
218 #else 221 #else
219 #define MAYBE_Basic Basic 222 #define MAYBE_Basic Basic
220 #endif 223 #endif
221 // Tests basic PDF rendering. This can be broken depending on bad merges with 224 // Tests basic PDF rendering. This can be broken depending on bad merges with
222 // the vendor, so it's important that we have basic sanity checking. 225 // the vendor, so it's important that we have basic sanity checking.
223 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Basic) { 226 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Basic) {
224 ASSERT_NO_FATAL_FAILURE(Load()); 227 ASSERT_NO_FATAL_FAILURE(Load());
225 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); 228 ASSERT_NO_FATAL_FAILURE(WaitForResponse());
226 // OS X uses CoreText, and FreeType renders slightly different on Linux and 229 // OS X uses CoreText, and FreeType renders slightly different on Linux and
227 // Win. 230 // Win.
228 #if defined(OS_MACOSX) 231 #if defined(OS_MACOSX)
229 // The bots render differently than locally, see http://crbug.com/142531. 232 // The bots render differently than locally, see http://crbug.com/142531.
230 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_mac.png") || 233 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_mac.png") ||
231 VerifySnapshot("pdf_browsertest_mac2.png")); 234 VerifySnapshot("pdf_browsertest_mac2.png"));
232 #elif defined(OS_LINUX) 235 #elif defined(OS_LINUX)
233 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_linux.png")); 236 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_linux.png"));
234 #else 237 #else
235 ASSERT_TRUE(VerifySnapshot("pdf_browsertest.png")); 238 ASSERT_TRUE(VerifySnapshot("pdf_browsertest.png"));
236 #endif 239 #endif
237 } 240 }
238 241
239 #if defined(OS_CHROMEOS) 242 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
240 // TODO(sanjeevr): http://crbug.com/79837 243 // TODO(sanjeevr): http://crbug.com/79837
241 #define MAYBE_Scroll DISABLED_Scroll 244 #define MAYBE_Scroll DISABLED_Scroll
242 #else 245 #else
243 #define MAYBE_Scroll Scroll 246 #define MAYBE_Scroll Scroll
244 #endif 247 #endif
245 // Tests that scrolling works. 248 // Tests that scrolling works.
246 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Scroll) { 249 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Scroll) {
247 ASSERT_NO_FATAL_FAILURE(Load()); 250 ASSERT_NO_FATAL_FAILURE(Load());
248 251
249 // We use wheel mouse event since that's the only one we can easily push to 252 // We use wheel mouse event since that's the only one we can easily push to
250 // the renderer. There's no way to push a cross-platform keyboard event at 253 // the renderer. There's no way to push a cross-platform keyboard event at
251 // the moment. 254 // the moment.
252 blink::WebMouseWheelEvent wheel_event; 255 blink::WebMouseWheelEvent wheel_event;
253 wheel_event.type = blink::WebInputEvent::MouseWheel; 256 wheel_event.type = blink::WebInputEvent::MouseWheel;
254 wheel_event.deltaY = -200; 257 wheel_event.deltaY = -200;
255 wheel_event.wheelTicksY = -2; 258 wheel_event.wheelTicksY = -2;
256 WebContents* web_contents = 259 WebContents* web_contents =
257 browser()->tab_strip_model()->GetActiveWebContents(); 260 browser()->tab_strip_model()->GetActiveWebContents();
258 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); 261 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event);
259 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); 262 ASSERT_NO_FATAL_FAILURE(WaitForResponse());
260 263
261 int y_offset = 0; 264 int y_offset = 0;
262 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 265 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
263 browser()->tab_strip_model()->GetActiveWebContents(), 266 browser()->tab_strip_model()->GetActiveWebContents(),
264 "window.domAutomationController.send(plugin.pageYOffset())", 267 "window.domAutomationController.send(plugin.pageYOffset())",
265 &y_offset)); 268 &y_offset));
266 ASSERT_GT(y_offset, 0); 269 ASSERT_GT(y_offset, 0);
267 } 270 }
268 271
269 #if defined(OS_CHROMEOS) 272 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
270 // TODO(sanjeevr): http://crbug.com/79837 273 // TODO(sanjeevr): http://crbug.com/79837
271 #define MAYBE_FindAndCopy DISABLED_FindAndCopy 274 #define MAYBE_FindAndCopy DISABLED_FindAndCopy
272 #else 275 #else
273 #define MAYBE_FindAndCopy FindAndCopy 276 #define MAYBE_FindAndCopy FindAndCopy
274 #endif 277 #endif
275 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_FindAndCopy) { 278 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_FindAndCopy) {
276 ASSERT_NO_FATAL_FAILURE(Load()); 279 ASSERT_NO_FATAL_FAILURE(Load());
277 // Verifies that find in page works. 280 // Verifies that find in page works.
278 ASSERT_EQ(3, ui_test_utils::FindInPage( 281 ASSERT_EQ(3, ui_test_utils::FindInPage(
279 browser()->tab_strip_model()->GetActiveWebContents(), 282 browser()->tab_strip_model()->GetActiveWebContents(),
(...skipping 17 matching lines...) Expand all
297 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &text); 300 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &text);
298 ASSERT_EQ("adipiscing", text); 301 ASSERT_EQ("adipiscing", text);
299 } 302 }
300 303
301 const int kLoadingNumberOfParts = 10; 304 const int kLoadingNumberOfParts = 10;
302 305
303 // Tests that loading async pdfs works correctly (i.e. document fully loads). 306 // Tests that loading async pdfs works correctly (i.e. document fully loads).
304 // This also loads all documents that used to crash, to ensure we don't have 307 // This also loads all documents that used to crash, to ensure we don't have
305 // regressions. 308 // regressions.
306 // If it flakes, reopen http://crbug.com/74548. 309 // If it flakes, reopen http://crbug.com/74548.
307 IN_PROC_BROWSER_TEST_P(PDFBrowserTest, Loading) { 310 #if !defined(GOOGLE_CHROME_BUILD)
311 #define MAYBE_Loading DISABLED_Loading
312 #else
313 #define MAYBE_Loading Loading
314 #endif
315 IN_PROC_BROWSER_TEST_P(PDFBrowserTest, MAYBE_Loading) {
308 ASSERT_TRUE(pdf_test_server()->InitializeAndWaitUntilReady()); 316 ASSERT_TRUE(pdf_test_server()->InitializeAndWaitUntilReady());
309 317
310 NavigationController* controller = 318 NavigationController* controller =
311 &(browser()->tab_strip_model()->GetActiveWebContents()->GetController()); 319 &(browser()->tab_strip_model()->GetActiveWebContents()->GetController());
312 content::NotificationRegistrar registrar; 320 content::NotificationRegistrar registrar;
313 registrar.Add(this, 321 registrar.Add(this,
314 content::NOTIFICATION_LOAD_STOP, 322 content::NOTIFICATION_LOAD_STOP,
315 content::Source<NavigationController>(controller)); 323 content::Source<NavigationController>(controller));
316 std::string base_url = std::string("/"); 324 std::string base_url = std::string("/");
317 325
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 content::WaitForLoadStop( 371 content::WaitForLoadStop(
364 browser()->tab_strip_model()->GetActiveWebContents()); 372 browser()->tab_strip_model()->GetActiveWebContents());
365 } 373 }
366 } 374 }
367 } 375 }
368 376
369 INSTANTIATE_TEST_CASE_P(PDFTestFiles, 377 INSTANTIATE_TEST_CASE_P(PDFTestFiles,
370 PDFBrowserTest, 378 PDFBrowserTest,
371 testing::Range(0, kLoadingNumberOfParts)); 379 testing::Range(0, kLoadingNumberOfParts));
372 380
373 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) 381 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_MACOSX)
374 // http://crbug.com/315160 382 // http://crbug.com/315160
375 #define MAYBE_Action DISABLED_Action 383 #define MAYBE_Action DISABLED_Action
376 #else 384 #else
377 #define MAYBE_Action Action 385 #define MAYBE_Action Action
378 #endif 386 #endif
379 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Action) { 387 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Action) {
380 ASSERT_NO_FATAL_FAILURE(Load()); 388 ASSERT_NO_FATAL_FAILURE(Load());
381 389
382 ASSERT_TRUE(content::ExecuteScript( 390 ASSERT_TRUE(content::ExecuteScript(
383 browser()->tab_strip_model()->GetActiveWebContents(), 391 browser()->tab_strip_model()->GetActiveWebContents(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 browser()->tab_strip_model()->GetActiveWebContents(), 426 browser()->tab_strip_model()->GetActiveWebContents(),
419 "reloadPDF();")); 427 "reloadPDF();"));
420 observer.Wait(); 428 observer.Wait();
421 429
422 ASSERT_EQ("success", 430 ASSERT_EQ("success",
423 browser()->tab_strip_model()->GetActiveWebContents()-> 431 browser()->tab_strip_model()->GetActiveWebContents()->
424 GetURL().query()); 432 GetURL().query());
425 } 433 }
426 434
427 } // namespace 435 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698