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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura_browsertest.cc

Issue 949473002: Avoid unnecessary casts in NavigationControllerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 | « content/browser/web_contents/web_contents_view_aura.cc ('k') | no next file » | 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 "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 570
571 // Do a few navigations initiated by the page. 571 // Do a few navigations initiated by the page.
572 // Screenshots should never be captured since these are all in-page 572 // Screenshots should never be captured since these are all in-page
573 // navigations. 573 // navigations.
574 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 574 ExecuteSyncJSFunction(main_frame, "navigate_next()");
575 EXPECT_EQ(1, GetCurrentIndex()); 575 EXPECT_EQ(1, GetCurrentIndex());
576 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 576 ExecuteSyncJSFunction(main_frame, "navigate_next()");
577 EXPECT_EQ(2, GetCurrentIndex()); 577 EXPECT_EQ(2, GetCurrentIndex());
578 screenshot_manager()->WaitUntilScreenshotIsReady(); 578 screenshot_manager()->WaitUntilScreenshotIsReady();
579 579
580 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 580 NavigationEntryImpl* entry = web_contents->GetController().GetEntryAtIndex(2);
581 web_contents->GetController().GetEntryAtIndex(2));
582 EXPECT_FALSE(entry->screenshot().get()); 581 EXPECT_FALSE(entry->screenshot().get());
583 582
584 entry = NavigationEntryImpl::FromNavigationEntry( 583 entry = web_contents->GetController().GetEntryAtIndex(1);
585 web_contents->GetController().GetEntryAtIndex(1));
586 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 584 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
587 585
588 entry = NavigationEntryImpl::FromNavigationEntry( 586 entry = web_contents->GetController().GetEntryAtIndex(0);
589 web_contents->GetController().GetEntryAtIndex(0));
590 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 587 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
591 588
592 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 589 ExecuteSyncJSFunction(main_frame, "navigate_next()");
593 screenshot_manager()->WaitUntilScreenshotIsReady(); 590 screenshot_manager()->WaitUntilScreenshotIsReady();
594 591
595 entry = NavigationEntryImpl::FromNavigationEntry( 592 entry = web_contents->GetController().GetEntryAtIndex(2);
596 web_contents->GetController().GetEntryAtIndex(2));
597 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 593 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
598 594
599 entry = NavigationEntryImpl::FromNavigationEntry( 595 entry = web_contents->GetController().GetEntryAtIndex(3);
600 web_contents->GetController().GetEntryAtIndex(3));
601 EXPECT_FALSE(entry->screenshot().get()); 596 EXPECT_FALSE(entry->screenshot().get());
602 { 597 {
603 // Now, swipe right to navigate backwards. This should navigate away from 598 // Now, swipe right to navigate backwards. This should navigate away from
604 // index 3 to index 2. 599 // index 3 to index 2.
605 base::string16 expected_title = base::ASCIIToUTF16("Title: #2"); 600 base::string16 expected_title = base::ASCIIToUTF16("Title: #2");
606 content::TitleWatcher title_watcher(web_contents, expected_title); 601 content::TitleWatcher title_watcher(web_contents, expected_title);
607 aura::Window* content = web_contents->GetContentNativeView(); 602 aura::Window* content = web_contents->GetContentNativeView();
608 gfx::Rect bounds = content->GetBoundsInRootWindow(); 603 gfx::Rect bounds = content->GetBoundsInRootWindow();
609 ui::test::EventGenerator generator(content->GetRootWindow(), content); 604 ui::test::EventGenerator generator(content->GetRootWindow(), content);
610 generator.GestureScrollSequence( 605 generator.GestureScrollSequence(
611 gfx::Point(bounds.x() + 2, bounds.y() + 10), 606 gfx::Point(bounds.x() + 2, bounds.y() + 10),
612 gfx::Point(bounds.right() - 10, bounds.y() + 10), 607 gfx::Point(bounds.right() - 10, bounds.y() + 10),
613 base::TimeDelta::FromMilliseconds(20), 608 base::TimeDelta::FromMilliseconds(20),
614 1); 609 1);
615 base::string16 actual_title = title_watcher.WaitAndGetTitle(); 610 base::string16 actual_title = title_watcher.WaitAndGetTitle();
616 EXPECT_EQ(expected_title, actual_title); 611 EXPECT_EQ(expected_title, actual_title);
617 EXPECT_EQ(2, GetCurrentIndex()); 612 EXPECT_EQ(2, GetCurrentIndex());
618 screenshot_manager()->WaitUntilScreenshotIsReady(); 613 screenshot_manager()->WaitUntilScreenshotIsReady();
619 entry = NavigationEntryImpl::FromNavigationEntry( 614 entry = web_contents->GetController().GetEntryAtIndex(3);
620 web_contents->GetController().GetEntryAtIndex(3));
621 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 615 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
622 } 616 }
623 617
624 // Navigate a couple more times. 618 // Navigate a couple more times.
625 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 619 ExecuteSyncJSFunction(main_frame, "navigate_next()");
626 EXPECT_EQ(3, GetCurrentIndex()); 620 EXPECT_EQ(3, GetCurrentIndex());
627 ExecuteSyncJSFunction(main_frame, "navigate_next()"); 621 ExecuteSyncJSFunction(main_frame, "navigate_next()");
628 EXPECT_EQ(4, GetCurrentIndex()); 622 EXPECT_EQ(4, GetCurrentIndex());
629 screenshot_manager()->WaitUntilScreenshotIsReady(); 623 screenshot_manager()->WaitUntilScreenshotIsReady();
630 entry = NavigationEntryImpl::FromNavigationEntry( 624 entry = web_contents->GetController().GetEntryAtIndex(4);
631 web_contents->GetController().GetEntryAtIndex(4));
632 EXPECT_FALSE(entry->screenshot().get()); 625 EXPECT_FALSE(entry->screenshot().get());
633 626
634 { 627 {
635 // Navigate back in history. 628 // Navigate back in history.
636 base::string16 expected_title = base::ASCIIToUTF16("Title: #3"); 629 base::string16 expected_title = base::ASCIIToUTF16("Title: #3");
637 content::TitleWatcher title_watcher(web_contents, expected_title); 630 content::TitleWatcher title_watcher(web_contents, expected_title);
638 web_contents->GetController().GoBack(); 631 web_contents->GetController().GoBack();
639 base::string16 actual_title = title_watcher.WaitAndGetTitle(); 632 base::string16 actual_title = title_watcher.WaitAndGetTitle();
640 EXPECT_EQ(expected_title, actual_title); 633 EXPECT_EQ(expected_title, actual_title);
641 EXPECT_EQ(3, GetCurrentIndex()); 634 EXPECT_EQ(3, GetCurrentIndex());
642 screenshot_manager()->WaitUntilScreenshotIsReady(); 635 screenshot_manager()->WaitUntilScreenshotIsReady();
643 entry = NavigationEntryImpl::FromNavigationEntry( 636 entry = web_contents->GetController().GetEntryAtIndex(4);
644 web_contents->GetController().GetEntryAtIndex(4));
645 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 637 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
646 } 638 }
647 } 639 }
648 640
649 // Crashes under ThreadSanitizer, http://crbug.com/356758. 641 // Crashes under ThreadSanitizer, http://crbug.com/356758.
650 #if defined(THREAD_SANITIZER) 642 #if defined(THREAD_SANITIZER)
651 #define MAYBE_ScreenshotForSwappedOutRenderViews \ 643 #define MAYBE_ScreenshotForSwappedOutRenderViews \
652 DISABLED_ScreenshotForSwappedOutRenderViews 644 DISABLED_ScreenshotForSwappedOutRenderViews
653 #else 645 #else
654 #define MAYBE_ScreenshotForSwappedOutRenderViews \ 646 #define MAYBE_ScreenshotForSwappedOutRenderViews \
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 685
694 RenderViewHost* old_host = web_contents->GetRenderViewHost(); 686 RenderViewHost* old_host = web_contents->GetRenderViewHost();
695 web_contents->GetController().LoadURLWithParams(params); 687 web_contents->GetController().LoadURLWithParams(params);
696 WaitForLoadStop(web_contents); 688 WaitForLoadStop(web_contents);
697 screenshot_manager()->WaitUntilScreenshotIsReady(); 689 screenshot_manager()->WaitUntilScreenshotIsReady();
698 690
699 EXPECT_NE(old_host, web_contents->GetRenderViewHost()) 691 EXPECT_NE(old_host, web_contents->GetRenderViewHost())
700 << navigations[i].url.spec(); 692 << navigations[i].url.spec();
701 EXPECT_EQ(old_host, screenshot_manager()->screenshot_taken_for()); 693 EXPECT_EQ(old_host, screenshot_manager()->screenshot_taken_for());
702 694
703 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 695 NavigationEntryImpl* entry =
704 web_contents->GetController().GetEntryAtOffset(-1)); 696 web_contents->GetController().GetEntryAtOffset(-1);
705 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); 697 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry));
706 698
707 entry = NavigationEntryImpl::FromNavigationEntry( 699 entry = web_contents->GetController().GetLastCommittedEntry();
708 web_contents->GetController().GetLastCommittedEntry());
709 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry)); 700 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry));
710 EXPECT_FALSE(entry->screenshot().get()); 701 EXPECT_FALSE(entry->screenshot().get());
711 screenshot_manager()->Reset(); 702 screenshot_manager()->Reset();
712 } 703 }
713 704
714 // Increase the minimum interval between taking screenshots. 705 // Increase the minimum interval between taking screenshots.
715 set_min_screenshot_interval(60000); 706 set_min_screenshot_interval(60000);
716 707
717 // Navigate again. This should not take any screenshot because of the 708 // Navigate again. This should not take any screenshot because of the
718 // increased screenshot interval. 709 // increased screenshot interval.
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 details = dispatcher->OnEventFromSource(&release); 1138 details = dispatcher->OnEventFromSource(&release);
1148 ASSERT_FALSE(details.dispatcher_destroyed); 1139 ASSERT_FALSE(details.dispatcher_destroyed);
1149 WaitAFrame(); 1140 WaitAFrame();
1150 1141
1151 EXPECT_LT(0, tracker.num_overscroll_updates()); 1142 EXPECT_LT(0, tracker.num_overscroll_updates());
1152 EXPECT_FALSE(tracker.overscroll_completed()); 1143 EXPECT_FALSE(tracker.overscroll_completed());
1153 } 1144 }
1154 } 1145 }
1155 1146
1156 } // namespace content 1147 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698