| 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/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 Loading... |
| 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), |
| 31 waiting_for_update_rect_msg_with_size_(false), | 32 waiting_for_update_rect_msg_with_size_(false), |
| 32 last_update_rect_width_(-1), | 33 last_update_rect_width_(-1), |
| 33 last_update_rect_height_(-1) { | 34 last_update_rect_height_(-1) { |
| 34 // Listen to visibility changes so that a test can wait for these changes. | 35 // Listen to visibility changes so that a test can wait for these changes. |
| 35 registrar_.Add(this, | 36 registrar_.Add(this, |
| 36 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 37 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 37 Source<WebContents>(web_contents)); | 38 Source<WebContents>(web_contents)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 TestBrowserPluginGuest::~TestBrowserPluginGuest() { | 41 TestBrowserPluginGuest::~TestBrowserPluginGuest() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 91 } |
| 91 | 92 |
| 92 void TestBrowserPluginGuest::WaitForUpdateRectMsg() { | 93 void TestBrowserPluginGuest::WaitForUpdateRectMsg() { |
| 93 // Check if we already got any UpdateRect message. | 94 // Check if we already got any UpdateRect message. |
| 94 if (update_rect_count_ > 0) | 95 if (update_rect_count_ > 0) |
| 95 return; | 96 return; |
| 96 send_message_loop_runner_ = new MessageLoopRunner(); | 97 send_message_loop_runner_ = new MessageLoopRunner(); |
| 97 send_message_loop_runner_->Run(); | 98 send_message_loop_runner_->Run(); |
| 98 } | 99 } |
| 99 | 100 |
| 101 void TestBrowserPluginGuest::ResetUpdateRectCount() { |
| 102 update_rect_count_ = 0; |
| 103 } |
| 104 |
| 100 void TestBrowserPluginGuest::WaitForUpdateRectMsgWithSize(int width, | 105 void TestBrowserPluginGuest::WaitForUpdateRectMsgWithSize(int width, |
| 101 int height) { | 106 int height) { |
| 102 if (update_rect_count_ > 0 && | 107 if (update_rect_count_ > 0 && |
| 103 last_update_rect_width_ == width && | 108 last_update_rect_width_ == width && |
| 104 last_update_rect_height_ == height) { | 109 last_update_rect_height_ == height) { |
| 105 // We already saw this message. | 110 // We already saw this message. |
| 106 return; | 111 return; |
| 107 } | 112 } |
| 108 waiting_for_update_rect_msg_with_size_ = true; | 113 waiting_for_update_rect_msg_with_size_ = true; |
| 109 expected_width_ = width; | 114 expected_width_ = width; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void TestBrowserPluginGuest::WaitUntilHidden() { | 152 void TestBrowserPluginGuest::WaitUntilHidden() { |
| 148 if (was_hidden_observed_) { | 153 if (was_hidden_observed_) { |
| 149 was_hidden_observed_ = false; | 154 was_hidden_observed_ = false; |
| 150 return; | 155 return; |
| 151 } | 156 } |
| 152 was_hidden_message_loop_runner_ = new MessageLoopRunner(); | 157 was_hidden_message_loop_runner_ = new MessageLoopRunner(); |
| 153 was_hidden_message_loop_runner_->Run(); | 158 was_hidden_message_loop_runner_->Run(); |
| 154 was_hidden_observed_ = false; | 159 was_hidden_observed_ = false; |
| 155 } | 160 } |
| 156 | 161 |
| 162 void TestBrowserPluginGuest::WaitForStop() { |
| 163 if (stop_observed_) { |
| 164 stop_observed_ = false; |
| 165 return; |
| 166 } |
| 167 |
| 168 stop_message_loop_runner_ = new MessageLoopRunner(); |
| 169 stop_message_loop_runner_->Run(); |
| 170 stop_observed_ = false; |
| 171 } |
| 172 |
| 173 |
| 157 void TestBrowserPluginGuest::SetFocus(bool focused) { | 174 void TestBrowserPluginGuest::SetFocus(bool focused) { |
| 158 focus_observed_ = true; | 175 focus_observed_ = true; |
| 159 if (focus_message_loop_runner_) | 176 if (focus_message_loop_runner_) |
| 160 focus_message_loop_runner_->Quit(); | 177 focus_message_loop_runner_->Quit(); |
| 161 BrowserPluginGuest::SetFocus(focused); | 178 BrowserPluginGuest::SetFocus(focused); |
| 162 } | 179 } |
| 163 | 180 |
| 164 bool TestBrowserPluginGuest::ViewTakeFocus(bool reverse) { | 181 bool TestBrowserPluginGuest::ViewTakeFocus(bool reverse) { |
| 165 advance_focus_observed_ = true; | 182 advance_focus_observed_ = true; |
| 166 if (advance_focus_message_loop_runner_) | 183 if (advance_focus_message_loop_runner_) |
| 167 advance_focus_message_loop_runner_->Quit(); | 184 advance_focus_message_loop_runner_->Quit(); |
| 168 return BrowserPluginGuest::ViewTakeFocus(reverse); | 185 return BrowserPluginGuest::ViewTakeFocus(reverse); |
| 169 } | 186 } |
| 170 | 187 |
| 188 void TestBrowserPluginGuest::Stop() { |
| 189 stop_observed_ = true; |
| 190 if (stop_message_loop_runner_) |
| 191 stop_message_loop_runner_->Quit(); |
| 192 BrowserPluginGuest::Stop(); |
| 193 } |
| 194 |
| 171 } // namespace content | 195 } // namespace content |
| OLD | NEW |