OLD | NEW |
---|---|
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/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 EXPECT_EQ(1, GetCurrentIndex()); | 217 EXPECT_EQ(1, GetCurrentIndex()); |
218 ExecuteSyncJSFunction(view_host, "navigate_next()"); | 218 ExecuteSyncJSFunction(view_host, "navigate_next()"); |
219 EXPECT_EQ(2, GetCurrentIndex()); | 219 EXPECT_EQ(2, GetCurrentIndex()); |
220 web_contents->GetController().GoBack(); | 220 web_contents->GetController().GoBack(); |
221 EXPECT_EQ(1, GetCurrentIndex()); | 221 EXPECT_EQ(1, GetCurrentIndex()); |
222 | 222 |
223 aura::Window* content = web_contents->GetView()->GetContentNativeView(); | 223 aura::Window* content = web_contents->GetView()->GetContentNativeView(); |
224 aura::RootWindow* root_window = content->GetRootWindow(); | 224 aura::RootWindow* root_window = content->GetRootWindow(); |
225 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 225 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
226 | 226 |
227 | |
228 // Each call to GetCurrentIndex involves blocking until the current | |
229 // MessageLoop is idle. Without a delay in scheduling draws, the | |
230 // MessageLoop doesn't become idle until the animation triggered by the | |
231 // preceding touch event completes; since each such animation takes 200ms, | |
232 // this causes the test to timeout. | |
233 root_window->DelayDrawsForTesting(base::TimeDelta::FromMilliseconds(10)); | |
Ian Vollick
2013/03/04 13:50:50
SetDrawDelayForTesting, perhaps? DelayDrawsForTest
| |
234 | |
227 base::TimeDelta timestamp; | 235 base::TimeDelta timestamp; |
228 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 236 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
229 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), | 237 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), |
230 0, timestamp); | 238 0, timestamp); |
231 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 239 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
232 EXPECT_EQ(1, GetCurrentIndex()); | 240 EXPECT_EQ(1, GetCurrentIndex()); |
233 | 241 |
234 timestamp += base::TimeDelta::FromMilliseconds(10); | 242 timestamp += base::TimeDelta::FromMilliseconds(10); |
235 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, | 243 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, |
236 gfx::Point(bounds.right() - 10, bounds.y() + 5), | 244 gfx::Point(bounds.right() - 10, bounds.y() + 5), |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 web_contents->GetController().GetEntryAtOffset(-1)); | 417 web_contents->GetController().GetEntryAtOffset(-1)); |
410 EXPECT_TRUE(entry->screenshot().get()); | 418 EXPECT_TRUE(entry->screenshot().get()); |
411 | 419 |
412 entry = NavigationEntryImpl::FromNavigationEntry( | 420 entry = NavigationEntryImpl::FromNavigationEntry( |
413 web_contents->GetController().GetActiveEntry()); | 421 web_contents->GetController().GetActiveEntry()); |
414 EXPECT_FALSE(entry->screenshot().get()); | 422 EXPECT_FALSE(entry->screenshot().get()); |
415 } | 423 } |
416 } | 424 } |
417 | 425 |
418 } // namespace content | 426 } // namespace content |
OLD | NEW |