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

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

Issue 2640473003: Convert tests to use the non-deprecated WebContentsObserver navigation methods. (Closed)
Patch Set: review comments Created 3 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 | « content/browser/web_contents/web_contents_impl_browsertest.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 <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 RenderViewHost* screenshot_taken_for_; 154 RenderViewHost* screenshot_taken_for_;
155 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 155 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
156 int waiting_for_screenshots_; 156 int waiting_for_screenshots_;
157 std::map<NavigationEntryImpl*, bool> screenshot_set_; 157 std::map<NavigationEntryImpl*, bool> screenshot_set_;
158 158
159 DISALLOW_COPY_AND_ASSIGN(ScreenshotTracker); 159 DISALLOW_COPY_AND_ASSIGN(ScreenshotTracker);
160 }; 160 };
161 161
162 class NavigationWatcher : public WebContentsObserver {
163 public:
164 explicit NavigationWatcher(WebContents* contents)
165 : WebContentsObserver(contents),
166 navigated_(false),
167 should_quit_loop_(false) {
168 }
169
170 ~NavigationWatcher() override {}
171
172 void WaitUntilNavigationStarts() {
173 if (navigated_)
174 return;
175 should_quit_loop_ = true;
176 base::RunLoop().Run();
177 }
178
179 private:
180 // Overridden from WebContentsObserver:
181 void DidStartNavigationToPendingEntry(const GURL& validated_url,
182 ReloadType reload_type) override {
183 navigated_ = true;
184 if (should_quit_loop_)
185 base::MessageLoop::current()->QuitWhenIdle();
186 }
187
188 bool navigated_;
189 bool should_quit_loop_;
190
191 DISALLOW_COPY_AND_ASSIGN(NavigationWatcher);
192 };
193
194 class InputEventMessageFilterWaitsForAcks : public BrowserMessageFilter { 162 class InputEventMessageFilterWaitsForAcks : public BrowserMessageFilter {
195 public: 163 public:
196 InputEventMessageFilterWaitsForAcks() 164 InputEventMessageFilterWaitsForAcks()
197 : BrowserMessageFilter(InputMsgStart), 165 : BrowserMessageFilter(InputMsgStart),
198 type_(blink::WebInputEvent::Undefined), 166 type_(blink::WebInputEvent::Undefined),
199 state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {} 167 state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {}
200 168
201 void WaitForAck(blink::WebInputEvent::Type type) { 169 void WaitForAck(blink::WebInputEvent::Type type) {
202 base::RunLoop run_loop; 170 base::RunLoop run_loop;
203 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 171 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 EXPECT_TRUE(controller.CanGoForward()); 809 EXPECT_TRUE(controller.CanGoForward());
842 810
843 aura::Window* content = web_contents->GetContentNativeView(); 811 aura::Window* content = web_contents->GetContentNativeView();
844 gfx::Rect bounds = content->GetBoundsInRootWindow(); 812 gfx::Rect bounds = content->GetBoundsInRootWindow();
845 ui::test::EventGenerator generator(content->GetRootWindow(), content); 813 ui::test::EventGenerator generator(content->GetRootWindow(), content);
846 814
847 // Do a swipe left to start a forward navigation. Then quickly do a swipe 815 // Do a swipe left to start a forward navigation. Then quickly do a swipe
848 // right. 816 // right.
849 base::string16 expected_title = base::ASCIIToUTF16("Title: #2"); 817 base::string16 expected_title = base::ASCIIToUTF16("Title: #2");
850 content::TitleWatcher title_watcher(web_contents, expected_title); 818 content::TitleWatcher title_watcher(web_contents, expected_title);
851 NavigationWatcher nav_watcher(web_contents); 819 TestNavigationManager nav_watcher(web_contents,
820 embedded_test_server()->GetURL("/overscroll_navigation.html#2"));
852 821
853 generator.GestureScrollSequence( 822 generator.GestureScrollSequence(
854 gfx::Point(bounds.right() - 10, bounds.y() + 10), 823 gfx::Point(bounds.right() - 10, bounds.y() + 10),
855 gfx::Point(bounds.x() + 2, bounds.y() + 10), 824 gfx::Point(bounds.x() + 2, bounds.y() + 10),
856 base::TimeDelta::FromMilliseconds(2000), 825 base::TimeDelta::FromMilliseconds(2000),
857 10); 826 10);
858 nav_watcher.WaitUntilNavigationStarts(); 827 nav_watcher.WaitForNavigationFinished();
clamy 2017/01/19 14:59:37 This doesn't correspond to the same point in time
jam 2017/01/20 05:52:16 I originally tried WaitForRequestStart() to keep
859 828
860 generator.GestureScrollSequence( 829 generator.GestureScrollSequence(
861 gfx::Point(bounds.x() + 2, bounds.y() + 10), 830 gfx::Point(bounds.x() + 2, bounds.y() + 10),
862 gfx::Point(bounds.right() - 10, bounds.y() + 10), 831 gfx::Point(bounds.right() - 10, bounds.y() + 10),
863 base::TimeDelta::FromMilliseconds(2000), 832 base::TimeDelta::FromMilliseconds(2000),
864 10); 833 10);
865 base::string16 actual_title = title_watcher.WaitAndGetTitle(); 834 base::string16 actual_title = title_watcher.WaitAndGetTitle();
866 EXPECT_EQ(expected_title, actual_title); 835 EXPECT_EQ(expected_title, actual_title);
867 836
868 EXPECT_EQ(2, GetCurrentIndex()); 837 EXPECT_EQ(2, GetCurrentIndex());
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 details = dispatcher->OnEventFromSource(&release); 1098 details = dispatcher->OnEventFromSource(&release);
1130 ASSERT_FALSE(details.dispatcher_destroyed); 1099 ASSERT_FALSE(details.dispatcher_destroyed);
1131 WaitAFrame(); 1100 WaitAFrame();
1132 1101
1133 EXPECT_LT(0, tracker.num_overscroll_updates()); 1102 EXPECT_LT(0, tracker.num_overscroll_updates());
1134 EXPECT_FALSE(tracker.overscroll_completed()); 1103 EXPECT_FALSE(tracker.overscroll_completed());
1135 } 1104 }
1136 } 1105 }
1137 1106
1138 } // namespace content 1107 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698