OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
9 #include "content/browser/web_contents/web_contents_view.h" | 9 #include "content/browser/web_contents/web_contents_view.h" |
10 #include "content/public/browser/load_notification_details.h" | 10 #include "content/public/browser/load_notification_details.h" |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 ADD_FAILURE() << "Progress values should be in order: " | 510 ADD_FAILURE() << "Progress values should be in order: " |
511 << ::testing::PrintToString(progresses); | 511 << ::testing::PrintToString(progresses); |
512 } | 512 } |
513 | 513 |
514 // ... and the last one should be 1.0, meaning complete. | 514 // ... and the last one should be 1.0, meaning complete. |
515 ASSERT_GE(progresses.size(), 1U) | 515 ASSERT_GE(progresses.size(), 1U) |
516 << "There should be at least one progress update"; | 516 << "There should be at least one progress update"; |
517 EXPECT_EQ(1.0, *progresses.rbegin()); | 517 EXPECT_EQ(1.0, *progresses.rbegin()); |
518 } | 518 } |
519 | 519 |
| 520 struct FirstVisuallyNonEmptyPaintObserver : public WebContentsObserver { |
| 521 FirstVisuallyNonEmptyPaintObserver(Shell* shell) |
| 522 : WebContentsObserver(shell->web_contents()), |
| 523 did_fist_visually_non_empty_paint_(false) {} |
| 524 |
| 525 virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE { |
| 526 did_fist_visually_non_empty_paint_ = true; |
| 527 on_did_first_visually_non_empty_paint_.Run(); |
| 528 } |
| 529 |
| 530 void WaitForDidFirstVisuallyNonEmptyPaint() { |
| 531 if (did_fist_visually_non_empty_paint_) |
| 532 return; |
| 533 base::RunLoop run_loop; |
| 534 on_did_first_visually_non_empty_paint_ = run_loop.QuitClosure(); |
| 535 run_loop.Run(); |
| 536 } |
| 537 |
| 538 base::Closure on_did_first_visually_non_empty_paint_; |
| 539 bool did_fist_visually_non_empty_paint_; |
| 540 }; |
| 541 |
| 542 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, FirstVisuallyNonEmptyPaint) { |
| 543 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 544 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer( |
| 545 new FirstVisuallyNonEmptyPaintObserver(shell())); |
| 546 |
| 547 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
| 548 |
| 549 observer->WaitForDidFirstVisuallyNonEmptyPaint(); |
| 550 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); |
| 551 } |
| 552 |
520 } // namespace content | 553 } // namespace content |
521 | 554 |
OLD | NEW |