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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 25336003: Use root window's coordinates when updating cursor in Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win-specific hack removed Created 7 years 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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // Show the view. Since the cursor was visible when the view was hidden, 671 // Show the view. Since the cursor was visible when the view was hidden,
672 // a message is expected to be sent. 672 // a message is expected to be sent.
673 sink_->ClearMessages(); 673 sink_->ClearMessages();
674 view_->WasShown(); 674 view_->WasShown();
675 EXPECT_TRUE(sink_->GetUniqueMessageMatching( 675 EXPECT_TRUE(sink_->GetUniqueMessageMatching(
676 InputMsg_CursorVisibilityChange::ID)); 676 InputMsg_CursorVisibilityChange::ID));
677 677
678 cursor_client.RemoveObserver(view_); 678 cursor_client.RemoveObserver(view_);
679 } 679 }
680 680
681 TEST_F(RenderWidgetHostViewAuraTest, UpdateCursorIfOverSelf) {
682 view_->InitAsChild(NULL);
683 aura::client::ParentWindowWithContext(
684 view_->GetNativeView(),
685 parent_view_->GetNativeView()->GetRootWindow(),
686 gfx::Rect());
687
688 // Note that all coordinates in this test are screen coordinates.
689 view_->SetBounds(gfx::Rect(60, 60, 100, 100));
690 view_->Show();
691
692 aura::test::TestCursorClient cursor_client(
693 parent_view_->GetNativeView()->GetRootWindow());
694
695 // Cursor is in the middle of the window.
696 cursor_client.reset_calls_to_set_cursor();
697 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(110, 110));
698 view_->UpdateCursorIfOverSelf();
699 EXPECT_EQ(1, cursor_client.calls_to_set_cursor());
700
701 // Cursor is near the top of the window.
702 cursor_client.reset_calls_to_set_cursor();
703 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(80, 65));
704 view_->UpdateCursorIfOverSelf();
705 EXPECT_EQ(1, cursor_client.calls_to_set_cursor());
706
707 // Cursor is near the bottom of the window.
708 cursor_client.reset_calls_to_set_cursor();
709 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(159, 159));
710 view_->UpdateCursorIfOverSelf();
711 EXPECT_EQ(1, cursor_client.calls_to_set_cursor());
712
713 // Cursor is above the window.
714 cursor_client.reset_calls_to_set_cursor();
715 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(67, 59));
716 view_->UpdateCursorIfOverSelf();
717 EXPECT_EQ(0, cursor_client.calls_to_set_cursor());
718
719 // Cursor is below the window.
720 cursor_client.reset_calls_to_set_cursor();
721 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(161, 161));
722 view_->UpdateCursorIfOverSelf();
723 EXPECT_EQ(0, cursor_client.calls_to_set_cursor());
724 }
725
681 scoped_ptr<cc::CompositorFrame> MakeGLFrame(float scale_factor, 726 scoped_ptr<cc::CompositorFrame> MakeGLFrame(float scale_factor,
682 gfx::Size size, 727 gfx::Size size,
683 gfx::Rect damage) { 728 gfx::Rect damage) {
684 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 729 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
685 frame->metadata.device_scale_factor = scale_factor; 730 frame->metadata.device_scale_factor = scale_factor;
686 frame->gl_frame_data.reset(new cc::GLFrameData); 731 frame->gl_frame_data.reset(new cc::GLFrameData);
687 frame->gl_frame_data->sync_point = 1; 732 frame->gl_frame_data->sync_point = 1;
688 memset(frame->gl_frame_data->mailbox.name, '1', 64); 733 memset(frame->gl_frame_data->mailbox.name, '1', 64);
689 frame->gl_frame_data->size = size; 734 frame->gl_frame_data->size = size;
690 frame->gl_frame_data->sub_buffer_rect = damage; 735 frame->gl_frame_data->sub_buffer_rect = damage;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 view_->OnSwapCompositorFrame( 1150 view_->OnSwapCompositorFrame(
1106 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); 1151 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size)));
1107 1152
1108 // When we get a new frame with the same frame size in physical pixels, but a 1153 // When we get a new frame with the same frame size in physical pixels, but a
1109 // different scale, we should generate a new frame provider, as the final 1154 // different scale, we should generate a new frame provider, as the final
1110 // result will need to be scaled differently to the screen. 1155 // result will need to be scaled differently to the screen.
1111 EXPECT_NE(frame_provider.get(), view_->frame_provider_.get()); 1156 EXPECT_NE(frame_provider.get(), view_->frame_provider_.get());
1112 } 1157 }
1113 1158
1114 } // namespace content 1159 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/aura/test/test_cursor_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698