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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2583873002: Correctly update the popup window position (Closed)
Patch Set: test added Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/aura/window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
index a839178ca22e72bf2e79ef193216a039d719eb3b..ed465751e06643219c77ca1fe7a5ae74e9b5b374 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -430,6 +430,10 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
return event_handler()->pointer_state();
}
+ // In this unit test, |window_| is directly added to the root and is
+ // toplevel.
+ aura::Window* GetToplevelWindow() override { return window(); }
+
gfx::Size last_frame_size_;
std::unique_ptr<cc::CopyOutputRequest> last_copy_request_;
FakeWindowEventDispatcher* dispatcher_;
@@ -517,6 +521,20 @@ const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) {
return reinterpret_cast<const WebInputEvent*>(data);
}
+class MockRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
+ public:
+ MockRenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack)
+ : RenderWidgetHostViewAura(host, is_guest_view_hack) {}
+
+ ~MockRenderWidgetHostViewAura() override {}
+
+ protected:
+ aura::Window* GetToplevelWindow() override { return window(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostViewAura);
+};
+
} // namespace
class RenderWidgetHostViewAuraTest : public testing::Test {
@@ -542,6 +560,8 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
ImageTransportFactory::GetInstance()->GetContextFactory(),
ImageTransportFactory::GetInstance()->GetContextFactoryPrivate());
new wm::DefaultActivationClient(aura_test_helper_->root_window());
+ aura::client::SetScreenPositionClient(aura_test_helper_->root_window(),
+ &screen_position_client_);
browser_context_.reset(new TestBrowserContext);
process_host_ = new MockRenderProcessHost(browser_context_.get());
@@ -554,8 +574,8 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
parent_host_ = new RenderWidgetHostImpl(delegates_.back().get(),
process_host_, routing_id, false);
delegates_.back()->set_widget_host(parent_host_);
- parent_view_ = new RenderWidgetHostViewAura(parent_host_,
- is_guest_view_hack_);
+ parent_view_ =
+ new MockRenderWidgetHostViewAura(parent_host_, is_guest_view_hack_);
parent_view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(parent_view_->GetNativeView(),
aura_test_helper_->root_window(),
@@ -713,6 +733,7 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_;
std::unique_ptr<BrowserContext> browser_context_;
std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_;
+ wm::DefaultScreenPositionClient screen_position_client_;
MockRenderProcessHost* process_host_;
// Tests should set these to nullptr if they've already triggered their
@@ -1002,11 +1023,9 @@ TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) {
// Checks that a popup is positioned correctly relative to its parent using
// screen coordinates.
TEST_F(RenderWidgetHostViewAuraTest, PositionChildPopup) {
- wm::DefaultScreenPositionClient screen_position_client;
aura::Window* window = parent_view_->GetNativeView();
aura::Window* root = window->GetRootWindow();
- aura::client::SetScreenPositionClient(root, &screen_position_client);
parent_view_->SetBounds(gfx::Rect(10, 10, 800, 600));
gfx::Rect bounds_in_screen = parent_view_->GetViewBounds();
@@ -4200,9 +4219,8 @@ class RenderWidgetHostViewAuraWithViewHarnessTest
// the RWHVA as the view.
delete contents()->GetRenderViewHost()->GetWidget()->GetView();
// This instance is destroyed in the TearDown method below.
- view_ = new RenderWidgetHostViewAura(
- contents()->GetRenderViewHost()->GetWidget(),
- false);
+ view_ = new MockRenderWidgetHostViewAura(
+ contents()->GetRenderViewHost()->GetWidget(), false);
}
void TearDown() override {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/aura/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698