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

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

Issue 2317563004: Change blink::WebScreenInfo to content::ScreenInfo (Closed)
Patch Set: Fix Windows compile Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <tuple> 9 #include <tuple>
10 10
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) { 377 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) {
378 prehandle_keyboard_event_is_shortcut_ = is_shortcut; 378 prehandle_keyboard_event_is_shortcut_ = is_shortcut;
379 } 379 }
380 380
381 bool handle_wheel_event_called() const { return handle_wheel_event_called_; } 381 bool handle_wheel_event_called() const { return handle_wheel_event_called_; }
382 382
383 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; } 383 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; }
384 384
385 void SetScreenInfo(const blink::WebScreenInfo& screen_info) { 385 void SetScreenInfo(const ScreenInfo& screen_info) {
386 screen_info_ = screen_info; 386 screen_info_ = screen_info;
387 } 387 }
388 388
389 // RenderWidgetHostDelegate overrides. 389 // RenderWidgetHostDelegate overrides.
390 void GetScreenInfo(blink::WebScreenInfo* web_screen_info) override { 390 void GetScreenInfo(ScreenInfo* screen_info) override {
391 *web_screen_info = screen_info_; 391 *screen_info = screen_info_;
392 } 392 }
393 393
394 protected: 394 protected:
395 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 395 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
396 bool* is_keyboard_shortcut) override { 396 bool* is_keyboard_shortcut) override {
397 prehandle_keyboard_event_type_ = event.type; 397 prehandle_keyboard_event_type_ = event.type;
398 prehandle_keyboard_event_called_ = true; 398 prehandle_keyboard_event_called_ = true;
399 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; 399 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_;
400 return prehandle_keyboard_event_; 400 return prehandle_keyboard_event_;
401 } 401 }
(...skipping 25 matching lines...) Expand all
427 WebInputEvent::Type prehandle_keyboard_event_type_; 427 WebInputEvent::Type prehandle_keyboard_event_type_;
428 428
429 bool unhandled_keyboard_event_called_; 429 bool unhandled_keyboard_event_called_;
430 WebInputEvent::Type unhandled_keyboard_event_type_; 430 WebInputEvent::Type unhandled_keyboard_event_type_;
431 431
432 bool handle_wheel_event_; 432 bool handle_wheel_event_;
433 bool handle_wheel_event_called_; 433 bool handle_wheel_event_called_;
434 434
435 bool unresponsive_timer_fired_; 435 bool unresponsive_timer_fired_;
436 436
437 blink::WebScreenInfo screen_info_; 437 ScreenInfo screen_info_;
438 }; 438 };
439 439
440 // RenderWidgetHostTest -------------------------------------------------------- 440 // RenderWidgetHostTest --------------------------------------------------------
441 441
442 class RenderWidgetHostTest : public testing::Test { 442 class RenderWidgetHostTest : public testing::Test {
443 public: 443 public:
444 RenderWidgetHostTest() 444 RenderWidgetHostTest()
445 : process_(NULL), 445 : process_(NULL),
446 handle_key_press_event_(false), 446 handle_key_press_event_(false),
447 handle_mouse_event_(false), 447 handle_mouse_event_(false),
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 787
788 // A different size should be sent again, however. 788 // A different size should be sent again, however.
789 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); 789 view_->set_bounds(gfx::Rect(0, 0, 0, 31));
790 host_->WasResized(); 790 host_->WasResized();
791 EXPECT_FALSE(host_->resize_ack_pending_); 791 EXPECT_FALSE(host_->resize_ack_pending_);
792 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size); 792 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size);
793 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 793 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
794 } 794 }
795 795
796 // Test that a resize event is sent if WasResized() is called after a 796 // Test that a resize event is sent if WasResized() is called after a
797 // WebScreenInfo change. 797 // ScreenInfo change.
798 TEST_F(RenderWidgetHostTest, ResizeScreenInfo) { 798 TEST_F(RenderWidgetHostTest, ResizeScreenInfo) {
799 blink::WebScreenInfo screen_info; 799 ScreenInfo screen_info;
800 screen_info.deviceScaleFactor = 1.f; 800 screen_info.device_scale_factor = 1.f;
801 screen_info.rect = blink::WebRect(0, 0, 800, 600); 801 screen_info.rect = blink::WebRect(0, 0, 800, 600);
802 screen_info.availableRect = blink::WebRect(0, 0, 800, 600); 802 screen_info.available_rect = blink::WebRect(0, 0, 800, 600);
803 screen_info.orientationAngle = 0; 803 screen_info.orientation_angle = 0;
804 screen_info.orientationType = blink::WebScreenOrientationPortraitPrimary; 804 screen_info.orientation_type = SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY;
805 805
806 auto host_delegate = 806 auto host_delegate =
807 static_cast<MockRenderWidgetHostDelegate*>(host_->delegate()); 807 static_cast<MockRenderWidgetHostDelegate*>(host_->delegate());
808 808
809 host_delegate->SetScreenInfo(screen_info); 809 host_delegate->SetScreenInfo(screen_info);
810 host_->WasResized(); 810 host_->WasResized();
811 EXPECT_FALSE(host_->resize_ack_pending_); 811 EXPECT_FALSE(host_->resize_ack_pending_);
812 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 812 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
813 process_->sink().ClearMessages(); 813 process_->sink().ClearMessages();
814 814
815 screen_info.orientationAngle = 180; 815 screen_info.orientation_angle = 180;
816 screen_info.orientationType = blink::WebScreenOrientationLandscapePrimary; 816 screen_info.orientation_type = SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
817 817
818 host_delegate->SetScreenInfo(screen_info); 818 host_delegate->SetScreenInfo(screen_info);
819 host_->WasResized(); 819 host_->WasResized();
820 EXPECT_FALSE(host_->resize_ack_pending_); 820 EXPECT_FALSE(host_->resize_ack_pending_);
821 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 821 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
822 process_->sink().ClearMessages(); 822 process_->sink().ClearMessages();
823 823
824 screen_info.deviceScaleFactor = 2.f; 824 screen_info.device_scale_factor = 2.f;
825 825
826 host_delegate->SetScreenInfo(screen_info); 826 host_delegate->SetScreenInfo(screen_info);
827 host_->WasResized(); 827 host_->WasResized();
828 EXPECT_FALSE(host_->resize_ack_pending_); 828 EXPECT_FALSE(host_->resize_ack_pending_);
829 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 829 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
830 process_->sink().ClearMessages(); 830 process_->sink().ClearMessages();
831 831
832 // No screen change. 832 // No screen change.
833 host_delegate->SetScreenInfo(screen_info); 833 host_delegate->SetScreenInfo(screen_info);
834 host_->WasResized(); 834 host_->WasResized();
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 ui::LatencyInfo()); 1707 ui::LatencyInfo());
1708 1708
1709 1709
1710 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). 1710 // Tests RWHI::ForwardWheelEventWithLatencyInfo().
1711 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); 1711 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo());
1712 1712
1713 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1713 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1714 } 1714 }
1715 1715
1716 } // namespace content 1716 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698