OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_view.h" | 5 #include "ppapi/tests/test_view.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "ppapi/c/pp_time.h" | 9 #include "ppapi/c/pp_time.h" |
10 #include "ppapi/c/private/ppb_testing_private.h" | 10 #include "ppapi/c/private/ppb_testing_private.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 bool TestView::Init() { | 39 bool TestView::Init() { |
40 return CheckTestingInterface(); | 40 return CheckTestingInterface(); |
41 } | 41 } |
42 | 42 |
43 void TestView::RunTests(const std::string& filter) { | 43 void TestView::RunTests(const std::string& filter) { |
44 RUN_TEST(CreatedVisible, filter); | 44 RUN_TEST(CreatedVisible, filter); |
45 RUN_TEST(CreatedInvisible, filter); | 45 RUN_TEST(CreatedInvisible, filter); |
46 RUN_TEST(PageHideShow, filter); | 46 RUN_TEST(PageHideShow, filter); |
47 RUN_TEST(SizeChange, filter); | 47 RUN_TEST(SizeChange, filter); |
48 RUN_TEST(ClipChange, filter); | 48 RUN_TEST(ClipChange, filter); |
49 RUN_TEST(ScrollOffsetChange, filter); | |
49 } | 50 } |
50 | 51 |
51 bool TestView::WaitUntilViewChanged() { | 52 bool TestView::WaitUntilViewChanged() { |
52 // Schedule a callback so this step times out if we don't get a ViewChanged | 53 // Schedule a callback so this step times out if we don't get a ViewChanged |
53 // in a reasonable amount of time. | 54 // in a reasonable amount of time. |
54 pp::CompletionCallbackFactory<TestView> factory(this); | 55 pp::CompletionCallbackFactory<TestView> factory(this); |
55 pp::CompletionCallback timeout = | 56 pp::CompletionCallback timeout = |
56 factory.NewCallback(&TestView::QuitMessageLoop); | 57 factory.NewCallback(&TestView::QuitMessageLoop); |
57 pp::Module::Get()->core()->CallOnMainThread( | 58 pp::Module::Get()->core()->CallOnMainThread( |
58 kViewChangeTimeoutSec * 1000, timeout); | 59 kViewChangeTimeoutSec * 1000, timeout); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 desired_clip.set_height(desired_clip.height() - desired_clip.y()); | 193 desired_clip.set_height(desired_clip.height() - desired_clip.y()); |
193 | 194 |
194 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); | 195 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); |
195 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && | 196 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && |
196 pp::Module::Get()->core()->GetTime() - begin_time < | 197 pp::Module::Get()->core()->GetTime() - begin_time < |
197 kViewChangeTimeoutSec) { | 198 kViewChangeTimeoutSec) { |
198 } | 199 } |
199 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); | 200 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); |
200 PASS(); | 201 PASS(); |
201 } | 202 } |
203 | |
204 std::string TestView::TestScrollOffsetChange() { | |
205 instance_->EvalScript("document.body.style.width = '5000px';" | |
206 "document.body.style.height = '5000px';"); | |
207 instance_->EvalScript("window.scrollTo(5, 1);"); | |
208 | |
209 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); | |
210 while (WaitUntilViewChanged() && | |
211 last_view_.GetScrollOffset() != pp::Point(5, 1) && | |
212 pp::Module::Get()->core()->GetTime() - begin_time < | |
213 kViewChangeTimeoutSec) { | |
214 } | |
215 ASSERT_TRUE(last_view_.GetScrollOffset() == pp::Point(5, 1)); | |
dmichael (off chromium)
2014/06/16 22:31:56
Does ASSERT_EQ work? Not sure since I added the lo
raymes
2014/06/17 00:43:00
Done.
| |
216 | |
217 instance_->EvalScript("window.scrollTo(0, 0);"); | |
218 | |
219 begin_time = pp::Module::Get()->core()->GetTime(); | |
220 while (WaitUntilViewChanged() && | |
221 last_view_.GetScrollOffset() != pp::Point(0, 0) && | |
222 pp::Module::Get()->core()->GetTime() - begin_time < | |
223 kViewChangeTimeoutSec) { | |
224 } | |
225 ASSERT_TRUE(last_view_.GetScrollOffset() == pp::Point(0, 0)); | |
226 | |
227 PASS(); | |
228 } | |
OLD | NEW |