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

Side by Side Diff: content/browser/browser_plugin/test_browser_plugin_guest.cc

Issue 10917225: Browser Plugin: Reload and Stop operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nit Created 8 years, 3 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 | Annotate | Revision Log
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/browser_plugin/test_browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/test_browser_plugin_guest.h"
6 6
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" 8 #include "content/browser/browser_plugin/browser_plugin_guest.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 10 matching lines...) Expand all
21 TestBrowserPluginGuest::TestBrowserPluginGuest( 21 TestBrowserPluginGuest::TestBrowserPluginGuest(
22 int instance_id, 22 int instance_id,
23 WebContentsImpl* web_contents, 23 WebContentsImpl* web_contents,
24 RenderViewHost* render_view_host) 24 RenderViewHost* render_view_host)
25 : BrowserPluginGuest(instance_id, web_contents, render_view_host), 25 : BrowserPluginGuest(instance_id, web_contents, render_view_host),
26 update_rect_count_(0), 26 update_rect_count_(0),
27 crash_observed_(false), 27 crash_observed_(false),
28 focus_observed_(false), 28 focus_observed_(false),
29 advance_focus_observed_(false), 29 advance_focus_observed_(false),
30 was_hidden_observed_(false), 30 was_hidden_observed_(false),
31 stop_observed_(false),
32 reload_observed_(false),
31 waiting_for_update_rect_msg_with_size_(false), 33 waiting_for_update_rect_msg_with_size_(false),
32 last_update_rect_width_(-1), 34 last_update_rect_width_(-1),
33 last_update_rect_height_(-1) { 35 last_update_rect_height_(-1) {
34 // Listen to visibility changes so that a test can wait for these changes. 36 // Listen to visibility changes so that a test can wait for these changes.
35 registrar_.Add(this, 37 registrar_.Add(this,
36 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 38 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
37 Source<WebContents>(web_contents)); 39 Source<WebContents>(web_contents));
38 } 40 }
39 41
40 TestBrowserPluginGuest::~TestBrowserPluginGuest() { 42 TestBrowserPluginGuest::~TestBrowserPluginGuest() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 92 }
91 93
92 void TestBrowserPluginGuest::WaitForUpdateRectMsg() { 94 void TestBrowserPluginGuest::WaitForUpdateRectMsg() {
93 // Check if we already got any UpdateRect message. 95 // Check if we already got any UpdateRect message.
94 if (update_rect_count_ > 0) 96 if (update_rect_count_ > 0)
95 return; 97 return;
96 send_message_loop_runner_ = new MessageLoopRunner(); 98 send_message_loop_runner_ = new MessageLoopRunner();
97 send_message_loop_runner_->Run(); 99 send_message_loop_runner_->Run();
98 } 100 }
99 101
102 void TestBrowserPluginGuest::ResetUpdateRectCount() {
103 update_rect_count_ = 0;
104 }
105
100 void TestBrowserPluginGuest::WaitForUpdateRectMsgWithSize(int width, 106 void TestBrowserPluginGuest::WaitForUpdateRectMsgWithSize(int width,
101 int height) { 107 int height) {
102 if (update_rect_count_ > 0 && 108 if (update_rect_count_ > 0 &&
103 last_update_rect_width_ == width && 109 last_update_rect_width_ == width &&
104 last_update_rect_height_ == height) { 110 last_update_rect_height_ == height) {
105 // We already saw this message. 111 // We already saw this message.
106 return; 112 return;
107 } 113 }
108 waiting_for_update_rect_msg_with_size_ = true; 114 waiting_for_update_rect_msg_with_size_ = true;
109 expected_width_ = width; 115 expected_width_ = width;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void TestBrowserPluginGuest::WaitUntilHidden() { 153 void TestBrowserPluginGuest::WaitUntilHidden() {
148 if (was_hidden_observed_) { 154 if (was_hidden_observed_) {
149 was_hidden_observed_ = false; 155 was_hidden_observed_ = false;
150 return; 156 return;
151 } 157 }
152 was_hidden_message_loop_runner_ = new MessageLoopRunner(); 158 was_hidden_message_loop_runner_ = new MessageLoopRunner();
153 was_hidden_message_loop_runner_->Run(); 159 was_hidden_message_loop_runner_->Run();
154 was_hidden_observed_ = false; 160 was_hidden_observed_ = false;
155 } 161 }
156 162
163 void TestBrowserPluginGuest::WaitForReload() {
164 if (reload_observed_) {
165 reload_observed_ = false;
166 return;
167 }
168
169 reload_message_loop_runner_ = new MessageLoopRunner();
170 reload_message_loop_runner_->Run();
171 reload_observed_ = false;
172 }
173
174 void TestBrowserPluginGuest::WaitForStop() {
175 if (stop_observed_) {
176 stop_observed_ = false;
177 return;
178 }
179
180 stop_message_loop_runner_ = new MessageLoopRunner();
181 stop_message_loop_runner_->Run();
182 stop_observed_ = false;
183 }
184
185
157 void TestBrowserPluginGuest::SetFocus(bool focused) { 186 void TestBrowserPluginGuest::SetFocus(bool focused) {
158 focus_observed_ = true; 187 focus_observed_ = true;
159 if (focus_message_loop_runner_) 188 if (focus_message_loop_runner_)
160 focus_message_loop_runner_->Quit(); 189 focus_message_loop_runner_->Quit();
161 BrowserPluginGuest::SetFocus(focused); 190 BrowserPluginGuest::SetFocus(focused);
162 } 191 }
163 192
164 bool TestBrowserPluginGuest::ViewTakeFocus(bool reverse) { 193 bool TestBrowserPluginGuest::ViewTakeFocus(bool reverse) {
165 advance_focus_observed_ = true; 194 advance_focus_observed_ = true;
166 if (advance_focus_message_loop_runner_) 195 if (advance_focus_message_loop_runner_)
167 advance_focus_message_loop_runner_->Quit(); 196 advance_focus_message_loop_runner_->Quit();
168 return BrowserPluginGuest::ViewTakeFocus(reverse); 197 return BrowserPluginGuest::ViewTakeFocus(reverse);
169 } 198 }
170 199
200 void TestBrowserPluginGuest::Reload() {
201 reload_observed_ = true;
202 if (reload_message_loop_runner_)
203 reload_message_loop_runner_->Quit();
204 BrowserPluginGuest::Reload();
205 }
206
207 void TestBrowserPluginGuest::Stop() {
208 stop_observed_ = true;
209 if (stop_message_loop_runner_)
210 stop_message_loop_runner_->Quit();
211 BrowserPluginGuest::Stop();
212 }
213
171 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/test_browser_plugin_guest.h ('k') | content/common/browser_plugin_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698