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

Side by Side Diff: ppapi/tests/test_view.cc

Issue 861343005: Make ppapi TestView use default browser test timeouts rather than internal ones (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | 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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 RUN_TEST(ScrollOffsetChange, filter); 49 RUN_TEST(ScrollOffsetChange, filter);
50 } 50 }
51 51
52 bool TestView::WaitUntilViewChanged() { 52 bool TestView::WaitUntilViewChanged() {
53 // 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
54 // in a reasonable amount of time. 54 // in a reasonable amount of time.
55 pp::CompletionCallbackFactory<TestView> factory(this); 55 pp::CompletionCallbackFactory<TestView> factory(this);
56 pp::CompletionCallback timeout = 56 pp::CompletionCallback timeout =
57 factory.NewCallback(&TestView::QuitMessageLoop); 57 factory.NewCallback(&TestView::QuitMessageLoop);
58 pp::Module::Get()->core()->CallOnMainThread( 58 pp::Module::Get()->core()->CallOnMainThread(
59 kViewChangeTimeoutSec * 1000, timeout); 59 kViewChangeTimeoutSec * 1000, timeout);
benwells 2015/01/28 02:55:50 Can this be removed as well?
dmichael (off chromium) 2015/01/28 17:50:32 I'm not super familiar with this test, but the pat
60 60
61 size_t old_page_visibility_change_count = page_visibility_log_.size(); 61 size_t old_page_visibility_change_count = page_visibility_log_.size();
62 62
63 // Run a nested message loop. It will exit either on ViewChanged or if the 63 // Run a nested message loop. It will exit either on ViewChanged or if the
64 // timeout happens. 64 // timeout happens.
65 post_quit_on_view_changed_ = true; 65 post_quit_on_view_changed_ = true;
66 testing_interface_->RunMessageLoop(instance_->pp_instance()); 66 testing_interface_->RunMessageLoop(instance_->pp_instance());
67 post_quit_on_view_changed_ = false; 67 post_quit_on_view_changed_ = false;
68 68
69 // We know we got a view changed event if something was appended to the log. 69 // We know we got a view changed event if something was appended to the log.
(...skipping 27 matching lines...) Expand all
97 std::string TestView::TestPageHideShow() { 97 std::string TestView::TestPageHideShow() {
98 // Initial state should be visible. 98 // Initial state should be visible.
99 ASSERT_FALSE(page_visibility_log_.empty()); 99 ASSERT_FALSE(page_visibility_log_.empty());
100 ASSERT_TRUE(page_visibility_log_[0]); 100 ASSERT_TRUE(page_visibility_log_[0]);
101 101
102 // Now that we're alive, tell the test knows it can change our visibility. 102 // Now that we're alive, tell the test knows it can change our visibility.
103 instance_->ReportProgress("TestPageHideShow:Created"); 103 instance_->ReportProgress("TestPageHideShow:Created");
104 104
105 // Wait until we get a hide event, being careful to handle spurious 105 // Wait until we get a hide event, being careful to handle spurious
106 // notifications of ViewChanged. 106 // notifications of ViewChanged.
107 PP_Time begin_time = pp::Module::Get()->core()->GetTime();
108 while (WaitUntilViewChanged() && 107 while (WaitUntilViewChanged() &&
109 page_visibility_log_[page_visibility_log_.size() - 1] && 108 page_visibility_log_[page_visibility_log_.size() - 1]) {
110 pp::Module::Get()->core()->GetTime() - begin_time <
111 kViewChangeTimeoutSec) {
112 } 109 }
113 if (page_visibility_log_[page_visibility_log_.size() - 1]) { 110 if (page_visibility_log_[page_visibility_log_.size() - 1]) {
114 // Didn't get a view changed event that changed visibility (though there 111 // Didn't get a view changed event that changed visibility (though there
115 // may have been some that didn't change visibility). 112 // may have been some that didn't change visibility).
116 // Add more error message since this test has some extra requirements. 113 // Add more error message since this test has some extra requirements.
117 return "Didn't receive a hide event in timeout. NOTE: " 114 return "Didn't receive a hide event in timeout. NOTE: "
118 "This test requires tab visibility to change and won't pass if you " 115 "This test requires tab visibility to change and won't pass if you "
119 "just run it in a browser. Normally the UI test should handle " 116 "just run it in a browser. Normally the UI test should handle "
120 "this. You can also run manually by waiting 2 secs, creating a new " 117 "this. You can also run manually by waiting 2 secs, creating a new "
121 "tab, waiting 2 more secs, and closing the new tab."; 118 "tab, waiting 2 more secs, and closing the new tab.";
122 } 119 }
123 120
124 // Tell the test so it can show us again. 121 // Tell the test so it can show us again.
125 instance_->ReportProgress("TestPageHideShow:Hidden"); 122 instance_->ReportProgress("TestPageHideShow:Hidden");
126 123
127 // Wait until we get a show event. 124 // Wait until we get a show event.
128 begin_time = pp::Module::Get()->core()->GetTime();
129 while (WaitUntilViewChanged() && 125 while (WaitUntilViewChanged() &&
130 !page_visibility_log_[page_visibility_log_.size() - 1] && 126 !page_visibility_log_[page_visibility_log_.size() - 1]) {
131 pp::Module::Get()->core()->GetTime() - begin_time <
132 kViewChangeTimeoutSec) {
133 } 127 }
134 ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]); 128 ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]);
135 129
136 PASS(); 130 PASS();
137 } 131 }
138 132
139 std::string TestView::TestSizeChange() { 133 std::string TestView::TestSizeChange() {
140 pp::Rect original_rect = last_view_.GetRect(); 134 pp::Rect original_rect = last_view_.GetRect();
141 135
142 pp::Rect desired_rect = original_rect; 136 pp::Rect desired_rect = original_rect;
143 desired_rect.set_width(original_rect.width() + 10); 137 desired_rect.set_width(original_rect.width() + 10);
144 desired_rect.set_height(original_rect.height() + 12); 138 desired_rect.set_height(original_rect.height() + 12);
145 139
146 std::ostringstream script_stream; 140 std::ostringstream script_stream;
147 script_stream << "var plugin = document.getElementById('plugin');"; 141 script_stream << "var plugin = document.getElementById('plugin');";
148 script_stream << "plugin.setAttribute('width', " 142 script_stream << "plugin.setAttribute('width', "
149 << desired_rect.width() << ");"; 143 << desired_rect.width() << ");";
150 script_stream << "plugin.setAttribute('height', " 144 script_stream << "plugin.setAttribute('height', "
151 << desired_rect.height() << ");"; 145 << desired_rect.height() << ");";
152 146
153 instance_->EvalScript(script_stream.str()); 147 instance_->EvalScript(script_stream.str());
154 148
155 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); 149 while (WaitUntilViewChanged() && last_view_.GetRect() != desired_rect) {
156 while (WaitUntilViewChanged() && last_view_.GetRect() != desired_rect &&
157 pp::Module::Get()->core()->GetTime() - begin_time <
158 kViewChangeTimeoutSec) {
159 } 150 }
160 ASSERT_TRUE(last_view_.GetRect() == desired_rect); 151 ASSERT_TRUE(last_view_.GetRect() == desired_rect);
161 152
162 PASS(); 153 PASS();
163 } 154 }
164 155
165 std::string TestView::TestClipChange() { 156 std::string TestView::TestClipChange() {
166 pp::Rect original_rect = last_view_.GetRect(); 157 pp::Rect original_rect = last_view_.GetRect();
167 158
168 // Original clip should be the full frame. 159 // Original clip should be the full frame.
(...skipping 16 matching lines...) Expand all
185 "top:0px; width:1px; height:5000px;');" 176 "top:0px; width:1px; height:5000px;');"
186 << "document.body.appendChild(big);" 177 << "document.body.appendChild(big);"
187 << "window.scrollBy(0, " << original_rect.y() + clip_amount << ");"; 178 << "window.scrollBy(0, " << original_rect.y() + clip_amount << ");";
188 179
189 instance_->EvalScript(script_stream.str()); 180 instance_->EvalScript(script_stream.str());
190 181
191 pp::Rect desired_clip = original_clip; 182 pp::Rect desired_clip = original_clip;
192 desired_clip.set_y(clip_amount); 183 desired_clip.set_y(clip_amount);
193 desired_clip.set_height(desired_clip.height() - desired_clip.y()); 184 desired_clip.set_height(desired_clip.height() - desired_clip.y());
194 185
195 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); 186 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip) {
196 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip &&
197 pp::Module::Get()->core()->GetTime() - begin_time <
198 kViewChangeTimeoutSec) {
199 } 187 }
200 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); 188 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip);
201 PASS(); 189 PASS();
202 } 190 }
203 191
204 std::string TestView::TestScrollOffsetChange() { 192 std::string TestView::TestScrollOffsetChange() {
205 instance_->EvalScript("document.body.style.width = '5000px';" 193 instance_->EvalScript("document.body.style.width = '5000px';"
206 "document.body.style.height = '5000px';"); 194 "document.body.style.height = '5000px';");
207 instance_->EvalScript("window.scrollTo(5, 1);"); 195 instance_->EvalScript("window.scrollTo(5, 1);");
208 196
209 PP_Time begin_time = pp::Module::Get()->core()->GetTime();
210 while (WaitUntilViewChanged() && 197 while (WaitUntilViewChanged() &&
211 last_view_.GetScrollOffset() != pp::Point(5, 1) && 198 last_view_.GetScrollOffset() != pp::Point(5, 1)) {
212 pp::Module::Get()->core()->GetTime() - begin_time <
213 kViewChangeTimeoutSec) {
214 } 199 }
215 ASSERT_EQ(pp::Point(5, 1), last_view_.GetScrollOffset()); 200 ASSERT_EQ(pp::Point(5, 1), last_view_.GetScrollOffset());
216 201
217 instance_->EvalScript("window.scrollTo(0, 0);"); 202 instance_->EvalScript("window.scrollTo(0, 0);");
218 203
219 begin_time = pp::Module::Get()->core()->GetTime();
220 while (WaitUntilViewChanged() && 204 while (WaitUntilViewChanged() &&
221 last_view_.GetScrollOffset() != pp::Point(0, 0) && 205 last_view_.GetScrollOffset() != pp::Point(0, 0)) {
222 pp::Module::Get()->core()->GetTime() - begin_time <
223 kViewChangeTimeoutSec) {
224 } 206 }
225 ASSERT_EQ(pp::Point(0, 0), last_view_.GetScrollOffset()); 207 ASSERT_EQ(pp::Point(0, 0), last_view_.GetScrollOffset());
226 208
227 PASS(); 209 PASS();
228 } 210 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698