| 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/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (window_) | 209 if (window_) |
| 210 window_->RemoveObserver(this); | 210 window_->RemoveObserver(this); |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool destroyed() const { return destroyed_; } | 213 bool destroyed() const { return destroyed_; } |
| 214 | 214 |
| 215 // aura::WindowObserver overrides: | 215 // aura::WindowObserver overrides: |
| 216 void OnWindowDestroyed(aura::Window* window) override { | 216 void OnWindowDestroyed(aura::Window* window) override { |
| 217 CHECK_EQ(window, window_); | 217 CHECK_EQ(window, window_); |
| 218 destroyed_ = true; | 218 destroyed_ = true; |
| 219 window_ = NULL; | 219 window_ = nullptr; |
| 220 } | 220 } |
| 221 | 221 |
| 222 private: | 222 private: |
| 223 // Window that we're observing, or NULL if it's been destroyed. | 223 // Window that we're observing, or nullptr if it's been destroyed. |
| 224 aura::Window* window_; | 224 aura::Window* window_; |
| 225 | 225 |
| 226 // Was |window_| destroyed? | 226 // Was |window_| destroyed? |
| 227 bool destroyed_; | 227 bool destroyed_; |
| 228 | 228 |
| 229 DISALLOW_COPY_AND_ASSIGN(TestWindowObserver); | 229 DISALLOW_COPY_AND_ASSIGN(TestWindowObserver); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 class FakeSurfaceDamageObserver : public cc::SurfaceDamageObserver { |
| 233 public: |
| 234 void OnSurfaceDamaged(const cc::SurfaceId& id, bool* changed) override { |
| 235 *changed = true; |
| 236 } |
| 237 }; |
| 238 |
| 232 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { | 239 class FakeFrameSubscriber : public RenderWidgetHostViewFrameSubscriber { |
| 233 public: | 240 public: |
| 234 FakeFrameSubscriber(gfx::Size size, base::Callback<void(bool)> callback) | 241 FakeFrameSubscriber(gfx::Size size, base::Callback<void(bool)> callback) |
| 235 : size_(size), callback_(callback), should_capture_(true) {} | 242 : size_(size), callback_(callback), should_capture_(true) {} |
| 236 | 243 |
| 237 bool ShouldCaptureFrame(const gfx::Rect& damage_rect, | 244 bool ShouldCaptureFrame(const gfx::Rect& damage_rect, |
| 238 base::TimeTicks present_time, | 245 base::TimeTicks present_time, |
| 239 scoped_refptr<media::VideoFrame>* storage, | 246 scoped_refptr<media::VideoFrame>* storage, |
| 240 DeliverFrameCallback* callback) override { | 247 DeliverFrameCallback* callback) override { |
| 241 if (!should_capture_) | 248 if (!should_capture_) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 348 } |
| 342 | 349 |
| 343 bool HasFrameData() const { | 350 bool HasFrameData() const { |
| 344 return !surface_id().is_null(); | 351 return !surface_id().is_null(); |
| 345 } | 352 } |
| 346 | 353 |
| 347 bool released_front_lock_active() const { | 354 bool released_front_lock_active() const { |
| 348 return GetDelegatedFrameHost()->ReleasedFrontLockActiveForTesting(); | 355 return GetDelegatedFrameHost()->ReleasedFrontLockActiveForTesting(); |
| 349 } | 356 } |
| 350 | 357 |
| 358 void ReturnResources(const cc::ReturnedResourceArray& resources) { |
| 359 GetDelegatedFrameHost()->ReturnResources(resources); |
| 360 } |
| 361 |
| 362 void ResetCompositor() { GetDelegatedFrameHost()->ResetCompositor(); } |
| 363 |
| 351 // A lock that doesn't actually do anything to the compositor, and does not | 364 // A lock that doesn't actually do anything to the compositor, and does not |
| 352 // time out. | 365 // time out. |
| 353 class FakeResizeLock : public ResizeLock { | 366 class FakeResizeLock : public ResizeLock { |
| 354 public: | 367 public: |
| 355 FakeResizeLock(const gfx::Size new_size, bool defer_compositor_lock) | 368 FakeResizeLock(const gfx::Size new_size, bool defer_compositor_lock) |
| 356 : ResizeLock(new_size, defer_compositor_lock) {} | 369 : ResizeLock(new_size, defer_compositor_lock) {} |
| 357 }; | 370 }; |
| 358 | 371 |
| 359 const ui::MotionEventAura& pointer_state_for_test() { | 372 const ui::MotionEventAura& pointer_state_for_test() { |
| 360 return pointer_state(); | 373 return pointer_state(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 class MockWindowObserver : public aura::WindowObserver { | 412 class MockWindowObserver : public aura::WindowObserver { |
| 400 public: | 413 public: |
| 401 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); | 414 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); |
| 402 }; | 415 }; |
| 403 | 416 |
| 404 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 417 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
| 405 base::PickleIterator iter(message); | 418 base::PickleIterator iter(message); |
| 406 const char* data; | 419 const char* data; |
| 407 int data_length; | 420 int data_length; |
| 408 if (!iter.ReadData(&data, &data_length)) | 421 if (!iter.ReadData(&data, &data_length)) |
| 409 return NULL; | 422 return nullptr; |
| 410 return reinterpret_cast<const WebInputEvent*>(data); | 423 return reinterpret_cast<const WebInputEvent*>(data); |
| 411 } | 424 } |
| 412 | 425 |
| 413 } // namespace | 426 } // namespace |
| 414 | 427 |
| 415 class RenderWidgetHostViewAuraTest : public testing::Test { | 428 class RenderWidgetHostViewAuraTest : public testing::Test { |
| 416 public: | 429 public: |
| 417 RenderWidgetHostViewAuraTest() | 430 RenderWidgetHostViewAuraTest() |
| 418 : widget_host_uses_shutdown_to_destroy_(false), | 431 : widget_host_uses_shutdown_to_destroy_(false), |
| 419 is_guest_view_hack_(false), | 432 is_guest_view_hack_(false), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 434 | 447 |
| 435 sink_ = &process_host_->sink(); | 448 sink_ = &process_host_->sink(); |
| 436 | 449 |
| 437 int32_t routing_id = process_host_->GetNextRoutingID(); | 450 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 438 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 451 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 439 parent_host_ = new RenderWidgetHostImpl(delegates_.back().get(), | 452 parent_host_ = new RenderWidgetHostImpl(delegates_.back().get(), |
| 440 process_host_, routing_id, false); | 453 process_host_, routing_id, false); |
| 441 delegates_.back()->set_widget_host(parent_host_); | 454 delegates_.back()->set_widget_host(parent_host_); |
| 442 parent_view_ = new RenderWidgetHostViewAura(parent_host_, | 455 parent_view_ = new RenderWidgetHostViewAura(parent_host_, |
| 443 is_guest_view_hack_); | 456 is_guest_view_hack_); |
| 444 parent_view_->InitAsChild(NULL); | 457 parent_view_->InitAsChild(nullptr); |
| 445 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), | 458 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), |
| 446 aura_test_helper_->root_window(), | 459 aura_test_helper_->root_window(), |
| 447 gfx::Rect()); | 460 gfx::Rect()); |
| 448 | 461 |
| 449 routing_id = process_host_->GetNextRoutingID(); | 462 routing_id = process_host_->GetNextRoutingID(); |
| 450 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 463 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 451 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), | 464 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), |
| 452 process_host_, routing_id, false); | 465 process_host_, routing_id, false); |
| 453 delegates_.back()->set_widget_host(widget_host_); | 466 delegates_.back()->set_widget_host(widget_host_); |
| 454 widget_host_->Init(); | 467 widget_host_->Init(); |
| 455 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); | 468 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); |
| 456 } | 469 } |
| 457 | 470 |
| 458 void TearDownEnvironment() { | 471 void TearDownEnvironment() { |
| 459 sink_ = NULL; | 472 sink_ = nullptr; |
| 460 process_host_ = NULL; | 473 process_host_ = nullptr; |
| 461 if (view_) { | 474 if (view_) { |
| 462 // For guest-views, |view_| is not the view used by |widget_host_|. | 475 // For guest-views, |view_| is not the view used by |widget_host_|. |
| 463 if (!is_guest_view_hack_) { | 476 if (!is_guest_view_hack_) { |
| 464 EXPECT_EQ(view_, widget_host_->GetView()); | 477 EXPECT_EQ(view_, widget_host_->GetView()); |
| 465 } | 478 } |
| 466 view_->Destroy(); | 479 view_->Destroy(); |
| 467 if (!is_guest_view_hack_) { | 480 if (!is_guest_view_hack_) { |
| 468 EXPECT_EQ(nullptr, widget_host_->GetView()); | 481 EXPECT_EQ(nullptr, widget_host_->GetView()); |
| 469 } | 482 } |
| 470 } | 483 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 595 |
| 583 bool is_guest_view_hack_; | 596 bool is_guest_view_hack_; |
| 584 | 597 |
| 585 base::MessageLoopForUI message_loop_; | 598 base::MessageLoopForUI message_loop_; |
| 586 BrowserThreadImpl browser_thread_for_ui_; | 599 BrowserThreadImpl browser_thread_for_ui_; |
| 587 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 600 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
| 588 std::unique_ptr<BrowserContext> browser_context_; | 601 std::unique_ptr<BrowserContext> browser_context_; |
| 589 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; | 602 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; |
| 590 MockRenderProcessHost* process_host_; | 603 MockRenderProcessHost* process_host_; |
| 591 | 604 |
| 592 // Tests should set these to NULL if they've already triggered their | 605 // Tests should set these to nullptr if they've already triggered their |
| 593 // destruction. | 606 // destruction. |
| 594 RenderWidgetHostImpl* parent_host_; | 607 RenderWidgetHostImpl* parent_host_; |
| 595 RenderWidgetHostViewAura* parent_view_; | 608 RenderWidgetHostViewAura* parent_view_; |
| 596 | 609 |
| 597 // Tests should set these to NULL if they've already triggered their | 610 // Tests should set these to nullptr if they've already triggered their |
| 598 // destruction. | 611 // destruction. |
| 599 RenderWidgetHostImpl* widget_host_; | 612 RenderWidgetHostImpl* widget_host_; |
| 600 FakeRenderWidgetHostViewAura* view_; | 613 FakeRenderWidgetHostViewAura* view_; |
| 601 | 614 |
| 602 IPC::TestSink* sink_; | 615 IPC::TestSink* sink_; |
| 603 | 616 |
| 604 private: | 617 private: |
| 605 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); | 618 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); |
| 606 }; | 619 }; |
| 607 | 620 |
| 608 // Helper class to instantiate RenderWidgetHostViewGuest which is backed | 621 // Helper class to instantiate RenderWidgetHostViewGuest which is backed |
| 609 // by an aura platform view. | 622 // by an aura platform view. |
| 610 class RenderWidgetHostViewGuestAuraTest : public RenderWidgetHostViewAuraTest { | 623 class RenderWidgetHostViewGuestAuraTest : public RenderWidgetHostViewAuraTest { |
| 611 public: | 624 public: |
| 612 RenderWidgetHostViewGuestAuraTest() { | 625 RenderWidgetHostViewGuestAuraTest() { |
| 613 // Use RWH::Shutdown to destroy RWH, instead of deleting. | 626 // Use RWH::Shutdown to destroy RWH, instead of deleting. |
| 614 // This will ensure that the RenderWidgetHostViewGuest is not leaked and | 627 // This will ensure that the RenderWidgetHostViewGuest is not leaked and |
| 615 // is deleted properly upon RWH going away. | 628 // is deleted properly upon RWH going away. |
| 616 set_widget_host_uses_shutdown_to_destroy(true); | 629 set_widget_host_uses_shutdown_to_destroy(true); |
| 617 } | 630 } |
| 618 | 631 |
| 619 // We explicitly invoke SetUp to allow gesture debounce customization. | 632 // We explicitly invoke SetUp to allow gesture debounce customization. |
| 620 void SetUp() override { | 633 void SetUp() override { |
| 621 is_guest_view_hack_ = true; | 634 is_guest_view_hack_ = true; |
| 622 | 635 |
| 623 RenderWidgetHostViewAuraTest::SetUp(); | 636 RenderWidgetHostViewAuraTest::SetUp(); |
| 624 | 637 |
| 625 guest_view_weak_ = (new RenderWidgetHostViewGuest( | 638 guest_view_weak_ = (new RenderWidgetHostViewGuest(widget_host_, nullptr, |
| 626 widget_host_, NULL, view_->GetWeakPtr()))->GetWeakPtr(); | 639 view_->GetWeakPtr())) |
| 640 ->GetWeakPtr(); |
| 627 } | 641 } |
| 628 | 642 |
| 629 void TearDown() override { | 643 void TearDown() override { |
| 630 // Internal override to do nothing, we clean up ourselves in the test body. | 644 // Internal override to do nothing, we clean up ourselves in the test body. |
| 631 // This helps us test that |guest_view_weak_| does not leak. | 645 // This helps us test that |guest_view_weak_| does not leak. |
| 632 } | 646 } |
| 633 | 647 |
| 634 protected: | 648 protected: |
| 635 base::WeakPtr<RenderWidgetHostViewBase> guest_view_weak_; | 649 base::WeakPtr<RenderWidgetHostViewBase> guest_view_weak_; |
| 636 | 650 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 657 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) { | 671 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) { |
| 658 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( | 672 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( |
| 659 debounce_interval_in_ms); | 673 debounce_interval_in_ms); |
| 660 | 674 |
| 661 RenderWidgetHostViewAuraTest::SetUp(); | 675 RenderWidgetHostViewAuraTest::SetUp(); |
| 662 | 676 |
| 663 view_->SetOverscrollControllerEnabled(true); | 677 view_->SetOverscrollControllerEnabled(true); |
| 664 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); | 678 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); |
| 665 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); | 679 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); |
| 666 | 680 |
| 667 view_->InitAsChild(NULL); | 681 view_->InitAsChild(nullptr); |
| 668 view_->SetBounds(gfx::Rect(0, 0, 400, 200)); | 682 view_->SetBounds(gfx::Rect(0, 0, 400, 200)); |
| 669 view_->Show(); | 683 view_->Show(); |
| 670 | 684 |
| 671 sink_->ClearMessages(); | 685 sink_->ClearMessages(); |
| 672 } | 686 } |
| 673 | 687 |
| 674 // TODO(jdduke): Simulate ui::Events, injecting through the view. | 688 // TODO(jdduke): Simulate ui::Events, injecting through the view. |
| 675 void SimulateMouseEvent(WebInputEvent::Type type) { | 689 void SimulateMouseEvent(WebInputEvent::Type type) { |
| 676 widget_host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); | 690 widget_host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); |
| 677 } | 691 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 // initialized. | 860 // initialized. |
| 847 TEST_F(RenderWidgetHostViewAuraTest, DestructionBeforeProperInitialization) { | 861 TEST_F(RenderWidgetHostViewAuraTest, DestructionBeforeProperInitialization) { |
| 848 // Terminate the test without initializing |view_|. | 862 // Terminate the test without initializing |view_|. |
| 849 } | 863 } |
| 850 | 864 |
| 851 // Checks that a fullscreen view has the correct show-state and receives the | 865 // Checks that a fullscreen view has the correct show-state and receives the |
| 852 // focus. | 866 // focus. |
| 853 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { | 867 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { |
| 854 view_->InitAsFullscreen(parent_view_); | 868 view_->InitAsFullscreen(parent_view_); |
| 855 aura::Window* window = view_->GetNativeView(); | 869 aura::Window* window = view_->GetNativeView(); |
| 856 ASSERT_TRUE(window != NULL); | 870 ASSERT_TRUE(window != nullptr); |
| 857 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, | 871 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, |
| 858 window->GetProperty(aura::client::kShowStateKey)); | 872 window->GetProperty(aura::client::kShowStateKey)); |
| 859 | 873 |
| 860 // Check that we requested and received the focus. | 874 // Check that we requested and received the focus. |
| 861 EXPECT_TRUE(window->HasFocus()); | 875 EXPECT_TRUE(window->HasFocus()); |
| 862 | 876 |
| 863 // Check that we'll also say it's okay to activate the window when there's an | 877 // Check that we'll also say it's okay to activate the window when there's an |
| 864 // ActivationClient defined. | 878 // ActivationClient defined. |
| 865 EXPECT_TRUE(view_->ShouldActivate()); | 879 EXPECT_TRUE(view_->ShouldActivate()); |
| 866 } | 880 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 893 view_->SetBounds(bounds_in_screen); | 907 view_->SetBounds(bounds_in_screen); |
| 894 final_bounds_in_screen = view_->GetViewBounds(); | 908 final_bounds_in_screen = view_->GetViewBounds(); |
| 895 EXPECT_EQ(final_bounds_in_screen.ToString(), bounds_in_screen.ToString()); | 909 EXPECT_EQ(final_bounds_in_screen.ToString(), bounds_in_screen.ToString()); |
| 896 | 910 |
| 897 // Verify that setting the size does not alter the origin. | 911 // Verify that setting the size does not alter the origin. |
| 898 gfx::Point original_origin = window->bounds().origin(); | 912 gfx::Point original_origin = window->bounds().origin(); |
| 899 view_->SetSize(gfx::Size(120, 120)); | 913 view_->SetSize(gfx::Size(120, 120)); |
| 900 gfx::Point new_origin = window->bounds().origin(); | 914 gfx::Point new_origin = window->bounds().origin(); |
| 901 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); | 915 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); |
| 902 | 916 |
| 903 aura::client::SetScreenPositionClient(root, NULL); | 917 aura::client::SetScreenPositionClient(root, nullptr); |
| 904 } | 918 } |
| 905 | 919 |
| 906 // Checks that moving parent sends new screen bounds. | 920 // Checks that moving parent sends new screen bounds. |
| 907 TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { | 921 TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { |
| 908 view_->InitAsChild(NULL); | 922 view_->InitAsChild(nullptr); |
| 909 | 923 |
| 910 aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); | 924 aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); |
| 911 | 925 |
| 912 aura::test::TestWindowDelegate delegate1, delegate2; | 926 aura::test::TestWindowDelegate delegate1, delegate2; |
| 913 std::unique_ptr<aura::Window> parent1(new aura::Window(&delegate1)); | 927 std::unique_ptr<aura::Window> parent1(new aura::Window(&delegate1)); |
| 914 parent1->Init(ui::LAYER_TEXTURED); | 928 parent1->Init(ui::LAYER_TEXTURED); |
| 915 parent1->Show(); | 929 parent1->Show(); |
| 916 std::unique_ptr<aura::Window> parent2(new aura::Window(&delegate2)); | 930 std::unique_ptr<aura::Window> parent2(new aura::Window(&delegate2)); |
| 917 parent2->Init(ui::LAYER_TEXTURED); | 931 parent2->Init(ui::LAYER_TEXTURED); |
| 918 parent2->Show(); | 932 parent2->Show(); |
| 919 | 933 |
| 920 root->AddChild(parent1.get()); | 934 root->AddChild(parent1.get()); |
| 921 parent1->AddChild(parent2.get()); | 935 parent1->AddChild(parent2.get()); |
| 922 parent2->AddChild(view_->GetNativeView()); | 936 parent2->AddChild(view_->GetNativeView()); |
| 923 | 937 |
| 924 root->SetBounds(gfx::Rect(0, 0, 800, 600)); | 938 root->SetBounds(gfx::Rect(0, 0, 800, 600)); |
| 925 parent1->SetBounds(gfx::Rect(1, 1, 300, 300)); | 939 parent1->SetBounds(gfx::Rect(1, 1, 300, 300)); |
| 926 parent2->SetBounds(gfx::Rect(2, 2, 200, 200)); | 940 parent2->SetBounds(gfx::Rect(2, 2, 200, 200)); |
| 927 view_->SetBounds(gfx::Rect(3, 3, 100, 100)); | 941 view_->SetBounds(gfx::Rect(3, 3, 100, 100)); |
| 928 // view_ will be destroyed when parent is destroyed. | 942 // view_ will be destroyed when parent is destroyed. |
| 929 view_ = NULL; | 943 view_ = nullptr; |
| 930 | 944 |
| 931 // Flush the state after initial setup is done. | 945 // Flush the state after initial setup is done. |
| 932 widget_host_->OnMessageReceived( | 946 widget_host_->OnMessageReceived( |
| 933 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 947 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 934 widget_host_->OnMessageReceived( | 948 widget_host_->OnMessageReceived( |
| 935 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 949 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 936 sink_->ClearMessages(); | 950 sink_->ClearMessages(); |
| 937 | 951 |
| 938 // Move parents. | 952 // Move parents. |
| 939 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); | 953 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 961 widget_host_->OnMessageReceived( | 975 widget_host_->OnMessageReceived( |
| 962 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | 976 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 963 // There should not be any pending update. | 977 // There should not be any pending update. |
| 964 EXPECT_EQ(0U, sink_->message_count()); | 978 EXPECT_EQ(0U, sink_->message_count()); |
| 965 } | 979 } |
| 966 | 980 |
| 967 // Checks that a fullscreen view is destroyed when it loses the focus. | 981 // Checks that a fullscreen view is destroyed when it loses the focus. |
| 968 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { | 982 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { |
| 969 view_->InitAsFullscreen(parent_view_); | 983 view_->InitAsFullscreen(parent_view_); |
| 970 aura::Window* window = view_->GetNativeView(); | 984 aura::Window* window = view_->GetNativeView(); |
| 971 ASSERT_TRUE(window != NULL); | 985 ASSERT_TRUE(window != nullptr); |
| 972 ASSERT_TRUE(window->HasFocus()); | 986 ASSERT_TRUE(window->HasFocus()); |
| 973 | 987 |
| 974 // After we create and focus another window, the RWHVA's window should be | 988 // After we create and focus another window, the RWHVA's window should be |
| 975 // destroyed. | 989 // destroyed. |
| 976 TestWindowObserver observer(window); | 990 TestWindowObserver observer(window); |
| 977 aura::test::TestWindowDelegate delegate; | 991 aura::test::TestWindowDelegate delegate; |
| 978 std::unique_ptr<aura::Window> sibling(new aura::Window(&delegate)); | 992 std::unique_ptr<aura::Window> sibling(new aura::Window(&delegate)); |
| 979 sibling->Init(ui::LAYER_TEXTURED); | 993 sibling->Init(ui::LAYER_TEXTURED); |
| 980 sibling->Show(); | 994 sibling->Show(); |
| 981 window->parent()->AddChild(sibling.get()); | 995 window->parent()->AddChild(sibling.get()); |
| 982 sibling->Focus(); | 996 sibling->Focus(); |
| 983 ASSERT_TRUE(sibling->HasFocus()); | 997 ASSERT_TRUE(sibling->HasFocus()); |
| 984 ASSERT_TRUE(observer.destroyed()); | 998 ASSERT_TRUE(observer.destroyed()); |
| 985 | 999 |
| 986 widget_host_ = NULL; | 1000 widget_host_ = nullptr; |
| 987 view_ = NULL; | 1001 view_ = nullptr; |
| 988 } | 1002 } |
| 989 | 1003 |
| 990 // Checks that a popup view is destroyed when a user clicks outside of the popup | 1004 // Checks that a popup view is destroyed when a user clicks outside of the popup |
| 991 // view and focus does not change. This is the case when the user clicks on the | 1005 // view and focus does not change. This is the case when the user clicks on the |
| 992 // desktop background on Chrome OS. | 1006 // desktop background on Chrome OS. |
| 993 TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupClickOutsidePopup) { | 1007 TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupClickOutsidePopup) { |
| 994 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); | 1008 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); |
| 995 parent_view_->Focus(); | 1009 parent_view_->Focus(); |
| 996 EXPECT_TRUE(parent_view_->HasFocus()); | 1010 EXPECT_TRUE(parent_view_->HasFocus()); |
| 997 | 1011 |
| 998 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); | 1012 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); |
| 999 aura::Window* window = view_->GetNativeView(); | 1013 aura::Window* window = view_->GetNativeView(); |
| 1000 ASSERT_TRUE(window != NULL); | 1014 ASSERT_TRUE(window != nullptr); |
| 1001 | 1015 |
| 1002 gfx::Point click_point; | 1016 gfx::Point click_point; |
| 1003 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(click_point)); | 1017 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(click_point)); |
| 1004 aura::Window* parent_window = parent_view_->GetNativeView(); | 1018 aura::Window* parent_window = parent_view_->GetNativeView(); |
| 1005 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(click_point)); | 1019 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(click_point)); |
| 1006 | 1020 |
| 1007 TestWindowObserver observer(window); | 1021 TestWindowObserver observer(window); |
| 1008 ui::test::EventGenerator generator(window->GetRootWindow(), click_point); | 1022 ui::test::EventGenerator generator(window->GetRootWindow(), click_point); |
| 1009 generator.ClickLeftButton(); | 1023 generator.ClickLeftButton(); |
| 1010 ASSERT_TRUE(parent_view_->HasFocus()); | 1024 ASSERT_TRUE(parent_view_->HasFocus()); |
| 1011 ASSERT_TRUE(observer.destroyed()); | 1025 ASSERT_TRUE(observer.destroyed()); |
| 1012 | 1026 |
| 1013 widget_host_ = NULL; | 1027 widget_host_ = nullptr; |
| 1014 view_ = NULL; | 1028 view_ = nullptr; |
| 1015 } | 1029 } |
| 1016 | 1030 |
| 1017 // Checks that a popup view is destroyed when a user taps outside of the popup | 1031 // Checks that a popup view is destroyed when a user taps outside of the popup |
| 1018 // view and focus does not change. This is the case when the user taps the | 1032 // view and focus does not change. This is the case when the user taps the |
| 1019 // desktop background on Chrome OS. | 1033 // desktop background on Chrome OS. |
| 1020 TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupTapOutsidePopup) { | 1034 TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupTapOutsidePopup) { |
| 1021 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); | 1035 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); |
| 1022 parent_view_->Focus(); | 1036 parent_view_->Focus(); |
| 1023 EXPECT_TRUE(parent_view_->HasFocus()); | 1037 EXPECT_TRUE(parent_view_->HasFocus()); |
| 1024 | 1038 |
| 1025 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); | 1039 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); |
| 1026 aura::Window* window = view_->GetNativeView(); | 1040 aura::Window* window = view_->GetNativeView(); |
| 1027 ASSERT_TRUE(window != NULL); | 1041 ASSERT_TRUE(window != nullptr); |
| 1028 | 1042 |
| 1029 gfx::Point tap_point; | 1043 gfx::Point tap_point; |
| 1030 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(tap_point)); | 1044 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(tap_point)); |
| 1031 aura::Window* parent_window = parent_view_->GetNativeView(); | 1045 aura::Window* parent_window = parent_view_->GetNativeView(); |
| 1032 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(tap_point)); | 1046 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(tap_point)); |
| 1033 | 1047 |
| 1034 TestWindowObserver observer(window); | 1048 TestWindowObserver observer(window); |
| 1035 ui::test::EventGenerator generator(window->GetRootWindow(), tap_point); | 1049 ui::test::EventGenerator generator(window->GetRootWindow(), tap_point); |
| 1036 generator.GestureTapAt(tap_point); | 1050 generator.GestureTapAt(tap_point); |
| 1037 ASSERT_TRUE(parent_view_->HasFocus()); | 1051 ASSERT_TRUE(parent_view_->HasFocus()); |
| 1038 ASSERT_TRUE(observer.destroyed()); | 1052 ASSERT_TRUE(observer.destroyed()); |
| 1039 | 1053 |
| 1040 widget_host_ = NULL; | 1054 widget_host_ = nullptr; |
| 1041 view_ = NULL; | 1055 view_ = nullptr; |
| 1042 } | 1056 } |
| 1043 | 1057 |
| 1044 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1058 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1045 | 1059 |
| 1046 // On Desktop Linux, select boxes need mouse capture in order to work. Test that | 1060 // On Desktop Linux, select boxes need mouse capture in order to work. Test that |
| 1047 // when a select box is opened via a mouse press that it retains mouse capture | 1061 // when a select box is opened via a mouse press that it retains mouse capture |
| 1048 // after the mouse is released. | 1062 // after the mouse is released. |
| 1049 TEST_F(RenderWidgetHostViewAuraTest, PopupRetainsCaptureAfterMouseRelease) { | 1063 TEST_F(RenderWidgetHostViewAuraTest, PopupRetainsCaptureAfterMouseRelease) { |
| 1050 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); | 1064 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); |
| 1051 parent_view_->Focus(); | 1065 parent_view_->Focus(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 dialog_window->Init(ui::LAYER_TEXTURED); | 1098 dialog_window->Init(ui::LAYER_TEXTURED); |
| 1085 aura::client::ParentWindowWithContext( | 1099 aura::client::ParentWindowWithContext( |
| 1086 dialog_window.get(), popup_window, gfx::Rect()); | 1100 dialog_window.get(), popup_window, gfx::Rect()); |
| 1087 dialog_window->Show(); | 1101 dialog_window->Show(); |
| 1088 wm::ActivateWindow(dialog_window.get()); | 1102 wm::ActivateWindow(dialog_window.get()); |
| 1089 dialog_window->Focus(); | 1103 dialog_window->Focus(); |
| 1090 | 1104 |
| 1091 ASSERT_TRUE(wm::IsActiveWindow(dialog_window.get())); | 1105 ASSERT_TRUE(wm::IsActiveWindow(dialog_window.get())); |
| 1092 EXPECT_TRUE(observer.destroyed()); | 1106 EXPECT_TRUE(observer.destroyed()); |
| 1093 | 1107 |
| 1094 widget_host_ = NULL; | 1108 widget_host_ = nullptr; |
| 1095 view_ = NULL; | 1109 view_ = nullptr; |
| 1096 } | 1110 } |
| 1097 | 1111 |
| 1098 // Checks that IME-composition-event state is maintained correctly. | 1112 // Checks that IME-composition-event state is maintained correctly. |
| 1099 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { | 1113 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { |
| 1100 view_->InitAsChild(NULL); | 1114 view_->InitAsChild(nullptr); |
| 1101 view_->Show(); | 1115 view_->Show(); |
| 1102 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); | 1116 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); |
| 1103 | 1117 |
| 1104 ui::CompositionText composition_text; | 1118 ui::CompositionText composition_text; |
| 1105 composition_text.text = base::ASCIIToUTF16("|a|b"); | 1119 composition_text.text = base::ASCIIToUTF16("|a|b"); |
| 1106 | 1120 |
| 1107 // Focused segment | 1121 // Focused segment |
| 1108 composition_text.underlines.push_back( | 1122 composition_text.underlines.push_back( |
| 1109 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); | 1123 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); |
| 1110 | 1124 |
| 1111 // Non-focused segment, with different background color. | 1125 // Non-focused segment, with different background color. |
| 1112 composition_text.underlines.push_back( | 1126 composition_text.underlines.push_back( |
| 1113 ui::CompositionUnderline(3, 4, 0xff000000, false, 0xefcdab90)); | 1127 ui::CompositionUnderline(3, 4, 0xff000000, false, 0xefcdab90)); |
| 1114 | 1128 |
| 1115 const ui::CompositionUnderlines& underlines = composition_text.underlines; | 1129 const ui::CompositionUnderlines& underlines = composition_text.underlines; |
| 1116 | 1130 |
| 1117 // Caret is at the end. (This emulates Japanese MSIME 2007 and later) | 1131 // Caret is at the end. (This emulates Japanese MSIME 2007 and later) |
| 1118 composition_text.selection = gfx::Range(4); | 1132 composition_text.selection = gfx::Range(4); |
| 1119 | 1133 |
| 1120 sink_->ClearMessages(); | 1134 sink_->ClearMessages(); |
| 1121 view_->SetCompositionText(composition_text); | 1135 view_->SetCompositionText(composition_text); |
| 1122 EXPECT_TRUE(view_->has_composition_text_); | 1136 EXPECT_TRUE(view_->has_composition_text_); |
| 1123 { | 1137 { |
| 1124 const IPC::Message* msg = | 1138 const IPC::Message* msg = |
| 1125 sink_->GetFirstMessageMatching(InputMsg_ImeSetComposition::ID); | 1139 sink_->GetFirstMessageMatching(InputMsg_ImeSetComposition::ID); |
| 1126 ASSERT_TRUE(msg != NULL); | 1140 ASSERT_TRUE(msg != nullptr); |
| 1127 | 1141 |
| 1128 InputMsg_ImeSetComposition::Param params; | 1142 InputMsg_ImeSetComposition::Param params; |
| 1129 InputMsg_ImeSetComposition::Read(msg, ¶ms); | 1143 InputMsg_ImeSetComposition::Read(msg, ¶ms); |
| 1130 // composition text | 1144 // composition text |
| 1131 EXPECT_EQ(composition_text.text, std::get<0>(params)); | 1145 EXPECT_EQ(composition_text.text, std::get<0>(params)); |
| 1132 // underlines | 1146 // underlines |
| 1133 ASSERT_EQ(underlines.size(), std::get<1>(params).size()); | 1147 ASSERT_EQ(underlines.size(), std::get<1>(params).size()); |
| 1134 for (size_t i = 0; i < underlines.size(); ++i) { | 1148 for (size_t i = 0; i < underlines.size(); ++i) { |
| 1135 EXPECT_EQ(underlines[i].start_offset, std::get<1>(params)[i].startOffset); | 1149 EXPECT_EQ(underlines[i].start_offset, std::get<1>(params)[i].startOffset); |
| 1136 EXPECT_EQ(underlines[i].end_offset, std::get<1>(params)[i].endOffset); | 1150 EXPECT_EQ(underlines[i].end_offset, std::get<1>(params)[i].endOffset); |
| 1137 EXPECT_EQ(underlines[i].color, std::get<1>(params)[i].color); | 1151 EXPECT_EQ(underlines[i].color, std::get<1>(params)[i].color); |
| 1138 EXPECT_EQ(underlines[i].thick, std::get<1>(params)[i].thick); | 1152 EXPECT_EQ(underlines[i].thick, std::get<1>(params)[i].thick); |
| 1139 EXPECT_EQ(underlines[i].background_color, | 1153 EXPECT_EQ(underlines[i].background_color, |
| 1140 std::get<1>(params)[i].backgroundColor); | 1154 std::get<1>(params)[i].backgroundColor); |
| 1141 } | 1155 } |
| 1142 EXPECT_EQ(gfx::Range::InvalidRange(), std::get<2>(params)); | 1156 EXPECT_EQ(gfx::Range::InvalidRange(), std::get<2>(params)); |
| 1143 // highlighted range | 1157 // highlighted range |
| 1144 EXPECT_EQ(4, std::get<3>(params)) << "Should be the same to the caret pos"; | 1158 EXPECT_EQ(4, std::get<3>(params)) << "Should be the same to the caret pos"; |
| 1145 EXPECT_EQ(4, std::get<4>(params)) << "Should be the same to the caret pos"; | 1159 EXPECT_EQ(4, std::get<4>(params)) << "Should be the same to the caret pos"; |
| 1146 } | 1160 } |
| 1147 | 1161 |
| 1148 view_->ImeCancelComposition(); | 1162 view_->ImeCancelComposition(); |
| 1149 EXPECT_FALSE(view_->has_composition_text_); | 1163 EXPECT_FALSE(view_->has_composition_text_); |
| 1150 } | 1164 } |
| 1151 | 1165 |
| 1152 // Checks that sequence of IME-composition-event and mouse-event when mouse | 1166 // Checks that sequence of IME-composition-event and mouse-event when mouse |
| 1153 // clicking to cancel the composition. | 1167 // clicking to cancel the composition. |
| 1154 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { | 1168 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { |
| 1155 view_->InitAsChild(NULL); | 1169 view_->InitAsChild(nullptr); |
| 1156 view_->Show(); | 1170 view_->Show(); |
| 1157 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); | 1171 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); |
| 1158 | 1172 |
| 1159 ui::CompositionText composition_text; | 1173 ui::CompositionText composition_text; |
| 1160 composition_text.text = base::ASCIIToUTF16("|a|b"); | 1174 composition_text.text = base::ASCIIToUTF16("|a|b"); |
| 1161 | 1175 |
| 1162 // Focused segment | 1176 // Focused segment |
| 1163 composition_text.underlines.push_back( | 1177 composition_text.underlines.push_back( |
| 1164 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); | 1178 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); |
| 1165 | 1179 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1188 // Verify mouse event happens after the confirm-composition event. | 1202 // Verify mouse event happens after the confirm-composition event. |
| 1189 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, | 1203 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, |
| 1190 sink_->GetMessageAt(0)->type()); | 1204 sink_->GetMessageAt(0)->type()); |
| 1191 EXPECT_EQ(InputMsg_HandleInputEvent::ID, | 1205 EXPECT_EQ(InputMsg_HandleInputEvent::ID, |
| 1192 sink_->GetMessageAt(1)->type()); | 1206 sink_->GetMessageAt(1)->type()); |
| 1193 } | 1207 } |
| 1194 } | 1208 } |
| 1195 | 1209 |
| 1196 // Checks that touch-event state is maintained correctly. | 1210 // Checks that touch-event state is maintained correctly. |
| 1197 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { | 1211 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { |
| 1198 view_->InitAsChild(NULL); | 1212 view_->InitAsChild(nullptr); |
| 1199 view_->Show(); | 1213 view_->Show(); |
| 1200 GetSentMessageCountAndResetSink(); | 1214 GetSentMessageCountAndResetSink(); |
| 1201 | 1215 |
| 1202 // Start with no touch-event handler in the renderer. | 1216 // Start with no touch-event handler in the renderer. |
| 1203 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1217 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 1204 | 1218 |
| 1205 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 1219 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 1206 ui::EventTimeForNow()); | 1220 ui::EventTimeForNow()); |
| 1207 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1221 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1208 ui::EventTimeForNow()); | 1222 ui::EventTimeForNow()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 ui::EventTimeForNow()); | 1372 ui::EventTimeForNow()); |
| 1359 | 1373 |
| 1360 view_->OnTouchEvent(&cancel1); | 1374 view_->OnTouchEvent(&cancel1); |
| 1361 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1375 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1362 EXPECT_EQ(0U, pointer_state().GetPointerCount()); | 1376 EXPECT_EQ(0U, pointer_state().GetPointerCount()); |
| 1363 } | 1377 } |
| 1364 | 1378 |
| 1365 // Checks that touch-events are queued properly when there is a touch-event | 1379 // Checks that touch-events are queued properly when there is a touch-event |
| 1366 // handler on the page. | 1380 // handler on the page. |
| 1367 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1381 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
| 1368 view_->InitAsChild(NULL); | 1382 view_->InitAsChild(nullptr); |
| 1369 view_->Show(); | 1383 view_->Show(); |
| 1370 | 1384 |
| 1371 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1385 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1372 | 1386 |
| 1373 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 1387 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 1374 ui::EventTimeForNow()); | 1388 ui::EventTimeForNow()); |
| 1375 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1389 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1376 ui::EventTimeForNow()); | 1390 ui::EventTimeForNow()); |
| 1377 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 1391 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
| 1378 ui::EventTimeForNow()); | 1392 ui::EventTimeForNow()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1393 EXPECT_TRUE(move.synchronous_handling_disabled()); | 1407 EXPECT_TRUE(move.synchronous_handling_disabled()); |
| 1394 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); | 1408 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); |
| 1395 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 1409 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
| 1396 | 1410 |
| 1397 view_->OnTouchEvent(&release); | 1411 view_->OnTouchEvent(&release); |
| 1398 EXPECT_TRUE(release.synchronous_handling_disabled()); | 1412 EXPECT_TRUE(release.synchronous_handling_disabled()); |
| 1399 EXPECT_EQ(0U, pointer_state().GetPointerCount()); | 1413 EXPECT_EQ(0U, pointer_state().GetPointerCount()); |
| 1400 } | 1414 } |
| 1401 | 1415 |
| 1402 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { | 1416 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { |
| 1403 view_->InitAsChild(NULL); | 1417 view_->InitAsChild(nullptr); |
| 1404 aura::client::ParentWindowWithContext( | 1418 aura::client::ParentWindowWithContext( |
| 1405 view_->GetNativeView(), | 1419 view_->GetNativeView(), |
| 1406 parent_view_->GetNativeView()->GetRootWindow(), | 1420 parent_view_->GetNativeView()->GetRootWindow(), |
| 1407 gfx::Rect()); | 1421 gfx::Rect()); |
| 1408 sink_->ClearMessages(); | 1422 sink_->ClearMessages(); |
| 1409 view_->SetSize(gfx::Size(100, 100)); | 1423 view_->SetSize(gfx::Size(100, 100)); |
| 1410 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); | 1424 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); |
| 1411 EXPECT_EQ(1u, sink_->message_count()); | 1425 EXPECT_EQ(1u, sink_->message_count()); |
| 1412 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); | 1426 EXPECT_EQ(ViewMsg_Resize::ID, sink_->GetMessageAt(0)->type()); |
| 1413 { | 1427 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size | 1470 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size |
| 1457 EXPECT_EQ( | 1471 EXPECT_EQ( |
| 1458 "100x100", | 1472 "100x100", |
| 1459 std::get<0>(params).physical_backing_size.ToString()); // backing size | 1473 std::get<0>(params).physical_backing_size.ToString()); // backing size |
| 1460 } | 1474 } |
| 1461 } | 1475 } |
| 1462 | 1476 |
| 1463 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched | 1477 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched |
| 1464 // to the renderer at the correct times. | 1478 // to the renderer at the correct times. |
| 1465 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { | 1479 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { |
| 1466 view_->InitAsChild(NULL); | 1480 view_->InitAsChild(nullptr); |
| 1467 aura::client::ParentWindowWithContext( | 1481 aura::client::ParentWindowWithContext( |
| 1468 view_->GetNativeView(), | 1482 view_->GetNativeView(), |
| 1469 parent_view_->GetNativeView()->GetRootWindow(), | 1483 parent_view_->GetNativeView()->GetRootWindow(), |
| 1470 gfx::Rect()); | 1484 gfx::Rect()); |
| 1471 view_->SetSize(gfx::Size(100, 100)); | 1485 view_->SetSize(gfx::Size(100, 100)); |
| 1472 | 1486 |
| 1473 aura::test::TestCursorClient cursor_client( | 1487 aura::test::TestCursorClient cursor_client( |
| 1474 parent_view_->GetNativeView()->GetRootWindow()); | 1488 parent_view_->GetNativeView()->GetRootWindow()); |
| 1475 | 1489 |
| 1476 cursor_client.AddObserver(view_); | 1490 cursor_client.AddObserver(view_); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 // a message is expected to be sent. | 1551 // a message is expected to be sent. |
| 1538 sink_->ClearMessages(); | 1552 sink_->ClearMessages(); |
| 1539 view_->Show(); | 1553 view_->Show(); |
| 1540 EXPECT_TRUE(sink_->GetUniqueMessageMatching( | 1554 EXPECT_TRUE(sink_->GetUniqueMessageMatching( |
| 1541 InputMsg_CursorVisibilityChange::ID)); | 1555 InputMsg_CursorVisibilityChange::ID)); |
| 1542 | 1556 |
| 1543 cursor_client.RemoveObserver(view_); | 1557 cursor_client.RemoveObserver(view_); |
| 1544 } | 1558 } |
| 1545 | 1559 |
| 1546 TEST_F(RenderWidgetHostViewAuraTest, UpdateCursorIfOverSelf) { | 1560 TEST_F(RenderWidgetHostViewAuraTest, UpdateCursorIfOverSelf) { |
| 1547 view_->InitAsChild(NULL); | 1561 view_->InitAsChild(nullptr); |
| 1548 aura::client::ParentWindowWithContext( | 1562 aura::client::ParentWindowWithContext( |
| 1549 view_->GetNativeView(), | 1563 view_->GetNativeView(), |
| 1550 parent_view_->GetNativeView()->GetRootWindow(), | 1564 parent_view_->GetNativeView()->GetRootWindow(), |
| 1551 gfx::Rect()); | 1565 gfx::Rect()); |
| 1552 | 1566 |
| 1553 // Note that all coordinates in this test are screen coordinates. | 1567 // Note that all coordinates in this test are screen coordinates. |
| 1554 view_->SetBounds(gfx::Rect(60, 60, 100, 100)); | 1568 view_->SetBounds(gfx::Rect(60, 60, 100, 100)); |
| 1555 view_->Show(); | 1569 view_->Show(); |
| 1556 | 1570 |
| 1557 aura::test::TestCursorClient cursor_client( | 1571 aura::test::TestCursorClient cursor_client( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 gfx::Size size, | 1606 gfx::Size size, |
| 1593 gfx::Rect damage) { | 1607 gfx::Rect damage) { |
| 1594 cc::CompositorFrame frame; | 1608 cc::CompositorFrame frame; |
| 1595 frame.metadata.device_scale_factor = scale_factor; | 1609 frame.metadata.device_scale_factor = scale_factor; |
| 1596 frame.delegated_frame_data.reset(new cc::DelegatedFrameData); | 1610 frame.delegated_frame_data.reset(new cc::DelegatedFrameData); |
| 1597 | 1611 |
| 1598 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | 1612 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
| 1599 pass->SetNew( | 1613 pass->SetNew( |
| 1600 cc::RenderPassId(1, 1), gfx::Rect(size), damage, gfx::Transform()); | 1614 cc::RenderPassId(1, 1), gfx::Rect(size), damage, gfx::Transform()); |
| 1601 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 1615 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 1616 if (!size.IsEmpty()) { |
| 1617 cc::TransferableResource resource; |
| 1618 resource.id = 1; |
| 1619 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); |
| 1620 } |
| 1602 return frame; | 1621 return frame; |
| 1603 } | 1622 } |
| 1604 | 1623 |
| 1624 // If the ui::Compositor has been reset then resources are returned back to the |
| 1625 // client in response to the swap. This test verifies that the returned |
| 1626 // resources are indeed reported as being in response to a swap. |
| 1627 TEST_F(RenderWidgetHostViewAuraTest, ResettingCompositorReturnsResources) { |
| 1628 FakeSurfaceDamageObserver damage_observer; |
| 1629 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1630 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1631 manager->AddObserver(&damage_observer); |
| 1632 |
| 1633 gfx::Size view_size(100, 100); |
| 1634 gfx::Rect view_rect(view_size); |
| 1635 |
| 1636 view_->InitAsChild(nullptr); |
| 1637 aura::client::ParentWindowWithContext( |
| 1638 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1639 gfx::Rect()); |
| 1640 view_->SetSize(view_size); |
| 1641 view_->Show(); |
| 1642 sink_->ClearMessages(); |
| 1643 |
| 1644 view_->ResetCompositor(); |
| 1645 |
| 1646 // Swapping a frame should trigger a swap ACK IPC because we have reset the |
| 1647 // compositor. |
| 1648 view_->OnSwapCompositorFrame(0, |
| 1649 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1650 EXPECT_EQ(1u, sink_->message_count()); |
| 1651 { |
| 1652 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 1653 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); |
| 1654 ViewMsg_ReclaimCompositorResources::Param params; |
| 1655 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); |
| 1656 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id |
| 1657 EXPECT_TRUE(std::get<1>(params)); // is_swap_ack |
| 1658 } |
| 1659 manager->RemoveObserver(&damage_observer); |
| 1660 } |
| 1661 |
| 1662 // This test verifies that returned resources do not require a pending ack. |
| 1663 TEST_F(RenderWidgetHostViewAuraTest, ReturnedResources) { |
| 1664 gfx::Size view_size(100, 100); |
| 1665 gfx::Rect view_rect(view_size); |
| 1666 |
| 1667 view_->InitAsChild(nullptr); |
| 1668 aura::client::ParentWindowWithContext( |
| 1669 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1670 gfx::Rect()); |
| 1671 view_->SetSize(view_size); |
| 1672 view_->Show(); |
| 1673 sink_->ClearMessages(); |
| 1674 |
| 1675 // Accumulate some returned resources. This should not trigger an IPC. |
| 1676 cc::ReturnedResourceArray resources; |
| 1677 cc::ReturnedResource resource; |
| 1678 resource.id = 1; |
| 1679 resources.push_back(resource); |
| 1680 view_->ReturnResources(resources); |
| 1681 EXPECT_EQ(1u, sink_->message_count()); |
| 1682 { |
| 1683 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 1684 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); |
| 1685 ViewMsg_ReclaimCompositorResources::Param params; |
| 1686 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); |
| 1687 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id |
| 1688 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack |
| 1689 } |
| 1690 } |
| 1691 |
| 1692 // This test verifies that when the output_surface_id changes, then |
| 1693 // DelegateFrameHost returns compositor resources without a swap ack. |
| 1694 TEST_F(RenderWidgetHostViewAuraTest, TwoOutputSurfaces) { |
| 1695 FakeSurfaceDamageObserver damage_observer; |
| 1696 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1697 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1698 manager->AddObserver(&damage_observer); |
| 1699 |
| 1700 gfx::Size view_size(100, 100); |
| 1701 gfx::Rect view_rect(view_size); |
| 1702 |
| 1703 view_->InitAsChild(nullptr); |
| 1704 aura::client::ParentWindowWithContext( |
| 1705 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1706 gfx::Rect()); |
| 1707 view_->SetSize(view_size); |
| 1708 view_->Show(); |
| 1709 sink_->ClearMessages(); |
| 1710 |
| 1711 view_->OnSwapCompositorFrame(0, |
| 1712 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1713 |
| 1714 // Accumulate some returned resources. This should not trigger an IPC. |
| 1715 cc::ReturnedResourceArray resources; |
| 1716 cc::ReturnedResource resource; |
| 1717 resource.id = 1; |
| 1718 resources.push_back(resource); |
| 1719 view_->ReturnResources(resources); |
| 1720 EXPECT_EQ(0u, sink_->message_count()); |
| 1721 |
| 1722 // Swap another CompositorFrame but this time from another output_surface_id. |
| 1723 // This should trigger a non-ACK ReclaimCompositorResources IPC. |
| 1724 view_->OnSwapCompositorFrame(1, |
| 1725 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1726 EXPECT_EQ(1u, sink_->message_count()); |
| 1727 { |
| 1728 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 1729 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); |
| 1730 ViewMsg_ReclaimCompositorResources::Param params; |
| 1731 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); |
| 1732 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id |
| 1733 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack |
| 1734 } |
| 1735 sink_->ClearMessages(); |
| 1736 |
| 1737 // Report that the surface is drawn to trigger an ACK. |
| 1738 cc::Surface* surface = manager->GetSurfaceForId(view_->surface_id()); |
| 1739 EXPECT_TRUE(surface); |
| 1740 surface->RunDrawCallbacks(cc::SurfaceDrawStatus::DRAWN); |
| 1741 EXPECT_EQ(1u, sink_->message_count()); |
| 1742 { |
| 1743 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 1744 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); |
| 1745 ViewMsg_ReclaimCompositorResources::Param params; |
| 1746 ViewMsg_ReclaimCompositorResources::Read(msg, ¶ms); |
| 1747 EXPECT_EQ(1u, std::get<0>(params)); // output_surface_id |
| 1748 EXPECT_EQ(true, std::get<1>(params)); // is_swap_ack |
| 1749 } |
| 1750 |
| 1751 manager->RemoveObserver(&damage_observer); |
| 1752 } |
| 1753 |
| 1605 // Resizing in fullscreen mode should send the up-to-date screen info. | 1754 // Resizing in fullscreen mode should send the up-to-date screen info. |
| 1606 // http://crbug.com/324350 | 1755 // http://crbug.com/324350 |
| 1607 TEST_F(RenderWidgetHostViewAuraTest, DISABLED_FullscreenResize) { | 1756 TEST_F(RenderWidgetHostViewAuraTest, DISABLED_FullscreenResize) { |
| 1608 aura::Window* root_window = aura_test_helper_->root_window(); | 1757 aura::Window* root_window = aura_test_helper_->root_window(); |
| 1609 root_window->SetLayoutManager(new FullscreenLayoutManager(root_window)); | 1758 root_window->SetLayoutManager(new FullscreenLayoutManager(root_window)); |
| 1610 view_->InitAsFullscreen(parent_view_); | 1759 view_->InitAsFullscreen(parent_view_); |
| 1611 view_->Show(); | 1760 view_->Show(); |
| 1612 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1761 widget_host_->ResetSizeAndRepaintPendingFlags(); |
| 1613 sink_->ClearMessages(); | 1762 sink_->ClearMessages(); |
| 1614 | 1763 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 ui::DrawWaiterForTest::WaitForCommit( | 1804 ui::DrawWaiterForTest::WaitForCommit( |
| 1656 root_window->GetHost()->compositor()); | 1805 root_window->GetHost()->compositor()); |
| 1657 } | 1806 } |
| 1658 } | 1807 } |
| 1659 | 1808 |
| 1660 // Swapping a frame should notify the window. | 1809 // Swapping a frame should notify the window. |
| 1661 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) { | 1810 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) { |
| 1662 gfx::Size view_size(100, 100); | 1811 gfx::Size view_size(100, 100); |
| 1663 gfx::Rect view_rect(view_size); | 1812 gfx::Rect view_rect(view_size); |
| 1664 | 1813 |
| 1665 view_->InitAsChild(NULL); | 1814 view_->InitAsChild(nullptr); |
| 1666 aura::client::ParentWindowWithContext( | 1815 aura::client::ParentWindowWithContext( |
| 1667 view_->GetNativeView(), | 1816 view_->GetNativeView(), |
| 1668 parent_view_->GetNativeView()->GetRootWindow(), | 1817 parent_view_->GetNativeView()->GetRootWindow(), |
| 1669 gfx::Rect()); | 1818 gfx::Rect()); |
| 1670 view_->SetSize(view_size); | 1819 view_->SetSize(view_size); |
| 1671 view_->Show(); | 1820 view_->Show(); |
| 1672 | 1821 |
| 1673 MockWindowObserver observer; | 1822 MockWindowObserver observer; |
| 1674 view_->window_->AddObserver(&observer); | 1823 view_->window_->AddObserver(&observer); |
| 1675 | 1824 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1687 | 1836 |
| 1688 view_->window_->RemoveObserver(&observer); | 1837 view_->window_->RemoveObserver(&observer); |
| 1689 } | 1838 } |
| 1690 | 1839 |
| 1691 // Recreating the layers for a window should cause Surface destruction to | 1840 // Recreating the layers for a window should cause Surface destruction to |
| 1692 // depend on both layers. | 1841 // depend on both layers. |
| 1693 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) { | 1842 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) { |
| 1694 gfx::Size view_size(100, 100); | 1843 gfx::Size view_size(100, 100); |
| 1695 gfx::Rect view_rect(view_size); | 1844 gfx::Rect view_rect(view_size); |
| 1696 | 1845 |
| 1697 view_->InitAsChild(NULL); | 1846 view_->InitAsChild(nullptr); |
| 1698 aura::client::ParentWindowWithContext( | 1847 aura::client::ParentWindowWithContext( |
| 1699 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), | 1848 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1700 gfx::Rect()); | 1849 gfx::Rect()); |
| 1701 view_->SetSize(view_size); | 1850 view_->SetSize(view_size); |
| 1702 view_->Show(); | 1851 view_->Show(); |
| 1703 | 1852 |
| 1704 view_->OnSwapCompositorFrame(0, | 1853 view_->OnSwapCompositorFrame(0, |
| 1705 MakeDelegatedFrame(1.f, view_size, view_rect)); | 1854 MakeDelegatedFrame(1.f, view_size, view_rect)); |
| 1706 std::unique_ptr<ui::LayerTreeOwner> cloned_owner( | 1855 std::unique_ptr<ui::LayerTreeOwner> cloned_owner( |
| 1707 wm::RecreateLayers(view_->GetNativeView(), nullptr)); | 1856 wm::RecreateLayers(view_->GetNativeView(), nullptr)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1720 // If the view size is larger than the compositor frame then extra layers | 1869 // If the view size is larger than the compositor frame then extra layers |
| 1721 // should be created to fill the gap. | 1870 // should be created to fill the gap. |
| 1722 TEST_F(RenderWidgetHostViewAuraTest, DelegatedFrameGutter) { | 1871 TEST_F(RenderWidgetHostViewAuraTest, DelegatedFrameGutter) { |
| 1723 gfx::Size large_size(100, 100); | 1872 gfx::Size large_size(100, 100); |
| 1724 gfx::Size small_size(40, 45); | 1873 gfx::Size small_size(40, 45); |
| 1725 gfx::Size medium_size(40, 95); | 1874 gfx::Size medium_size(40, 95); |
| 1726 | 1875 |
| 1727 // Prevent the DelegatedFrameHost from skipping frames. | 1876 // Prevent the DelegatedFrameHost from skipping frames. |
| 1728 view_->can_create_resize_lock_ = false; | 1877 view_->can_create_resize_lock_ = false; |
| 1729 | 1878 |
| 1730 view_->InitAsChild(NULL); | 1879 view_->InitAsChild(nullptr); |
| 1731 aura::client::ParentWindowWithContext( | 1880 aura::client::ParentWindowWithContext( |
| 1732 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), | 1881 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 1733 gfx::Rect()); | 1882 gfx::Rect()); |
| 1734 view_->SetSize(large_size); | 1883 view_->SetSize(large_size); |
| 1735 view_->Show(); | 1884 view_->Show(); |
| 1736 cc::CompositorFrame frame = | 1885 cc::CompositorFrame frame = |
| 1737 MakeDelegatedFrame(1.f, small_size, gfx::Rect(small_size)); | 1886 MakeDelegatedFrame(1.f, small_size, gfx::Rect(small_size)); |
| 1738 frame.metadata.root_background_color = SK_ColorRED; | 1887 frame.metadata.root_background_color = SK_ColorRED; |
| 1739 view_->OnSwapCompositorFrame(0, std::move(frame)); | 1888 view_->OnSwapCompositorFrame(0, std::move(frame)); |
| 1740 | 1889 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1768 view_->SetSize(small_size); | 1917 view_->SetSize(small_size); |
| 1769 ASSERT_EQ(0u, parent_layer->children().size()); | 1918 ASSERT_EQ(0u, parent_layer->children().size()); |
| 1770 } | 1919 } |
| 1771 | 1920 |
| 1772 TEST_F(RenderWidgetHostViewAuraTest, Resize) { | 1921 TEST_F(RenderWidgetHostViewAuraTest, Resize) { |
| 1773 gfx::Size size1(100, 100); | 1922 gfx::Size size1(100, 100); |
| 1774 gfx::Size size2(200, 200); | 1923 gfx::Size size2(200, 200); |
| 1775 gfx::Size size3(300, 300); | 1924 gfx::Size size3(300, 300); |
| 1776 | 1925 |
| 1777 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); | 1926 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); |
| 1778 view_->InitAsChild(NULL); | 1927 view_->InitAsChild(nullptr); |
| 1779 aura::client::ParentWindowWithContext( | 1928 aura::client::ParentWindowWithContext( |
| 1780 view_->GetNativeView(), root_window, gfx::Rect(size1)); | 1929 view_->GetNativeView(), root_window, gfx::Rect(size1)); |
| 1781 view_->Show(); | 1930 view_->Show(); |
| 1782 view_->SetSize(size1); | 1931 view_->SetSize(size1); |
| 1783 view_->OnSwapCompositorFrame( | 1932 view_->OnSwapCompositorFrame( |
| 1784 0, MakeDelegatedFrame(1.f, size1, gfx::Rect(size1))); | 1933 0, MakeDelegatedFrame(1.f, size1, gfx::Rect(size1))); |
| 1785 ui::DrawWaiterForTest::WaitForCommit( | 1934 ui::DrawWaiterForTest::WaitForCommit( |
| 1786 root_window->GetHost()->compositor()); | 1935 root_window->GetHost()->compositor()); |
| 1787 ViewHostMsg_UpdateRect_Params update_params; | 1936 ViewHostMsg_UpdateRect_Params update_params; |
| 1788 update_params.view_size = size1; | 1937 update_params.view_size = size1; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1815 view_->SetSize(size3); | 1964 view_->SetSize(size3); |
| 1816 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); | 1965 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); |
| 1817 EXPECT_EQ(0u, sink_->message_count()); | 1966 EXPECT_EQ(0u, sink_->message_count()); |
| 1818 | 1967 |
| 1819 // Receive a frame of the new size, should be skipped and not produce a Resize | 1968 // Receive a frame of the new size, should be skipped and not produce a Resize |
| 1820 // message. | 1969 // message. |
| 1821 view_->OnSwapCompositorFrame( | 1970 view_->OnSwapCompositorFrame( |
| 1822 0, MakeDelegatedFrame(1.f, size3, gfx::Rect(size3))); | 1971 0, MakeDelegatedFrame(1.f, size3, gfx::Rect(size3))); |
| 1823 // Expect the frame ack; | 1972 // Expect the frame ack; |
| 1824 EXPECT_EQ(1u, sink_->message_count()); | 1973 EXPECT_EQ(1u, sink_->message_count()); |
| 1825 EXPECT_EQ(ViewMsg_SwapCompositorFrameAck::ID, sink_->GetMessageAt(0)->type()); | 1974 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, |
| 1975 sink_->GetMessageAt(0)->type()); |
| 1826 sink_->ClearMessages(); | 1976 sink_->ClearMessages(); |
| 1827 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); | 1977 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); |
| 1828 | 1978 |
| 1829 // Receive a frame of the correct size, should not be skipped and, and should | 1979 // Receive a frame of the correct size, should not be skipped and, and should |
| 1830 // produce a Resize message after the commit. | 1980 // produce a Resize message after the commit. |
| 1831 view_->OnSwapCompositorFrame( | 1981 view_->OnSwapCompositorFrame( |
| 1832 0, MakeDelegatedFrame(1.f, size2, gfx::Rect(size2))); | 1982 0, MakeDelegatedFrame(1.f, size2, gfx::Rect(size2))); |
| 1833 cc::SurfaceId surface_id = view_->surface_id(); | 1983 cc::SurfaceId surface_id = view_->surface_id(); |
| 1834 if (surface_id.is_null()) { | 1984 if (surface_id.is_null()) { |
| 1835 // No frame ack yet. | 1985 // No frame ack yet. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1854 // call | 2004 // call |
| 1855 // ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow, | 2005 // ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow, |
| 1856 // which the above WaitForCommit may cause to be picked up. Be robust | 2006 // which the above WaitForCommit may cause to be picked up. Be robust |
| 1857 // to this extra IPC coming in. | 2007 // to this extra IPC coming in. |
| 1858 InputMsg_HandleInputEvent::Param params; | 2008 InputMsg_HandleInputEvent::Param params; |
| 1859 InputMsg_HandleInputEvent::Read(msg, ¶ms); | 2009 InputMsg_HandleInputEvent::Read(msg, ¶ms); |
| 1860 const blink::WebInputEvent* event = std::get<0>(params); | 2010 const blink::WebInputEvent* event = std::get<0>(params); |
| 1861 EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type); | 2011 EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type); |
| 1862 break; | 2012 break; |
| 1863 } | 2013 } |
| 1864 case ViewMsg_SwapCompositorFrameAck::ID: | 2014 case ViewMsg_ReclaimCompositorResources::ID: |
| 1865 break; | 2015 break; |
| 1866 case ViewMsg_Resize::ID: { | 2016 case ViewMsg_Resize::ID: { |
| 1867 EXPECT_FALSE(has_resize); | 2017 EXPECT_FALSE(has_resize); |
| 1868 ViewMsg_Resize::Param params; | 2018 ViewMsg_Resize::Param params; |
| 1869 ViewMsg_Resize::Read(msg, ¶ms); | 2019 ViewMsg_Resize::Read(msg, ¶ms); |
| 1870 EXPECT_EQ(size3.ToString(), std::get<0>(params).new_size.ToString()); | 2020 EXPECT_EQ(size3.ToString(), std::get<0>(params).new_size.ToString()); |
| 1871 has_resize = true; | 2021 has_resize = true; |
| 1872 break; | 2022 break; |
| 1873 } | 2023 } |
| 1874 default: | 2024 default: |
| 1875 ADD_FAILURE() << "Unexpected message " << msg->type(); | 2025 ADD_FAILURE() << "Unexpected message " << msg->type(); |
| 1876 break; | 2026 break; |
| 1877 } | 2027 } |
| 1878 } | 2028 } |
| 1879 EXPECT_TRUE(has_resize); | 2029 EXPECT_TRUE(has_resize); |
| 1880 update_params.view_size = size3; | 2030 update_params.view_size = size3; |
| 1881 widget_host_->OnMessageReceived( | 2031 widget_host_->OnMessageReceived( |
| 1882 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); | 2032 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); |
| 1883 sink_->ClearMessages(); | 2033 sink_->ClearMessages(); |
| 1884 } | 2034 } |
| 1885 | 2035 |
| 1886 // Skipped frames should not drop their damage. | 2036 // Skipped frames should not drop their damage. |
| 1887 TEST_F(RenderWidgetHostViewAuraTest, SkippedDelegatedFrames) { | 2037 TEST_F(RenderWidgetHostViewAuraTest, SkippedDelegatedFrames) { |
| 1888 gfx::Rect view_rect(100, 100); | 2038 gfx::Rect view_rect(100, 100); |
| 1889 gfx::Size frame_size = view_rect.size(); | 2039 gfx::Size frame_size = view_rect.size(); |
| 1890 | 2040 |
| 1891 view_->InitAsChild(NULL); | 2041 view_->InitAsChild(nullptr); |
| 1892 aura::client::ParentWindowWithContext( | 2042 aura::client::ParentWindowWithContext( |
| 1893 view_->GetNativeView(), | 2043 view_->GetNativeView(), |
| 1894 parent_view_->GetNativeView()->GetRootWindow(), | 2044 parent_view_->GetNativeView()->GetRootWindow(), |
| 1895 gfx::Rect()); | 2045 gfx::Rect()); |
| 1896 view_->SetSize(view_rect.size()); | 2046 view_->SetSize(view_rect.size()); |
| 1897 | 2047 |
| 1898 MockWindowObserver observer; | 2048 MockWindowObserver observer; |
| 1899 view_->window_->AddObserver(&observer); | 2049 view_->window_->AddObserver(&observer); |
| 1900 | 2050 |
| 1901 // A full frame of damage. | 2051 // A full frame of damage. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 testing::Mock::VerifyAndClearExpectations(&observer); | 2118 testing::Mock::VerifyAndClearExpectations(&observer); |
| 1969 view_->RunOnCompositingDidCommit(); | 2119 view_->RunOnCompositingDidCommit(); |
| 1970 | 2120 |
| 1971 view_->window_->RemoveObserver(&observer); | 2121 view_->window_->RemoveObserver(&observer); |
| 1972 } | 2122 } |
| 1973 | 2123 |
| 1974 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { | 2124 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { |
| 1975 gfx::Rect view_rect(100, 100); | 2125 gfx::Rect view_rect(100, 100); |
| 1976 gfx::Size frame_size = view_rect.size(); | 2126 gfx::Size frame_size = view_rect.size(); |
| 1977 | 2127 |
| 1978 view_->InitAsChild(NULL); | 2128 view_->InitAsChild(nullptr); |
| 1979 aura::client::ParentWindowWithContext( | 2129 aura::client::ParentWindowWithContext( |
| 1980 view_->GetNativeView(), | 2130 view_->GetNativeView(), |
| 1981 parent_view_->GetNativeView()->GetRootWindow(), | 2131 parent_view_->GetNativeView()->GetRootWindow(), |
| 1982 gfx::Rect()); | 2132 gfx::Rect()); |
| 1983 view_->SetSize(view_rect.size()); | 2133 view_->SetSize(view_rect.size()); |
| 1984 | 2134 |
| 1985 MockWindowObserver observer; | 2135 MockWindowObserver observer; |
| 1986 view_->window_->AddObserver(&observer); | 2136 view_->window_->AddObserver(&observer); |
| 1987 | 2137 |
| 1988 // Swap a frame. | 2138 // Swap a frame. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2009 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); | 2159 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); |
| 2010 view_->OnSwapCompositorFrame(3, | 2160 view_->OnSwapCompositorFrame(3, |
| 2011 MakeDelegatedFrame(1.f, frame_size, view_rect)); | 2161 MakeDelegatedFrame(1.f, frame_size, view_rect)); |
| 2012 testing::Mock::VerifyAndClearExpectations(&observer); | 2162 testing::Mock::VerifyAndClearExpectations(&observer); |
| 2013 view_->RunOnCompositingDidCommit(); | 2163 view_->RunOnCompositingDidCommit(); |
| 2014 | 2164 |
| 2015 view_->window_->RemoveObserver(&observer); | 2165 view_->window_->RemoveObserver(&observer); |
| 2016 } | 2166 } |
| 2017 | 2167 |
| 2018 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { | 2168 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { |
| 2019 view_->InitAsChild(NULL); | 2169 view_->InitAsChild(nullptr); |
| 2020 | 2170 |
| 2021 size_t max_renderer_frames = | 2171 size_t max_renderer_frames = |
| 2022 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2172 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
| 2023 ASSERT_LE(2u, max_renderer_frames); | 2173 ASSERT_LE(2u, max_renderer_frames); |
| 2024 size_t renderer_count = max_renderer_frames + 1; | 2174 size_t renderer_count = max_renderer_frames + 1; |
| 2025 gfx::Rect view_rect(100, 100); | 2175 gfx::Rect view_rect(100, 100); |
| 2026 gfx::Size frame_size = view_rect.size(); | 2176 gfx::Size frame_size = view_rect.size(); |
| 2027 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2177 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
| 2028 | 2178 |
| 2029 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2179 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
| 2030 new RenderWidgetHostImpl*[renderer_count]); | 2180 new RenderWidgetHostImpl*[renderer_count]); |
| 2031 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2181 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
| 2032 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2182 new FakeRenderWidgetHostViewAura*[renderer_count]); |
| 2033 | 2183 |
| 2034 // Create a bunch of renderers. | 2184 // Create a bunch of renderers. |
| 2035 for (size_t i = 0; i < renderer_count; ++i) { | 2185 for (size_t i = 0; i < renderer_count; ++i) { |
| 2036 int32_t routing_id = process_host_->GetNextRoutingID(); | 2186 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 2037 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2187 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 2038 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, | 2188 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, |
| 2039 routing_id, false); | 2189 routing_id, false); |
| 2040 delegates_.back()->set_widget_host(hosts[i]); | 2190 delegates_.back()->set_widget_host(hosts[i]); |
| 2041 hosts[i]->Init(); | 2191 hosts[i]->Init(); |
| 2042 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); | 2192 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); |
| 2043 views[i]->InitAsChild(NULL); | 2193 views[i]->InitAsChild(nullptr); |
| 2044 aura::client::ParentWindowWithContext( | 2194 aura::client::ParentWindowWithContext( |
| 2045 views[i]->GetNativeView(), | 2195 views[i]->GetNativeView(), |
| 2046 parent_view_->GetNativeView()->GetRootWindow(), | 2196 parent_view_->GetNativeView()->GetRootWindow(), |
| 2047 gfx::Rect()); | 2197 gfx::Rect()); |
| 2048 views[i]->SetSize(view_rect.size()); | 2198 views[i]->SetSize(view_rect.size()); |
| 2049 } | 2199 } |
| 2050 | 2200 |
| 2051 // Make each renderer visible, and swap a frame on it, then make it invisible. | 2201 // Make each renderer visible, and swap a frame on it, then make it invisible. |
| 2052 for (size_t i = 0; i < renderer_count; ++i) { | 2202 for (size_t i = 0; i < renderer_count; ++i) { |
| 2053 views[i]->Show(); | 2203 views[i]->Show(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 RendererFrameManager::GetInstance()->set_max_handles( | 2324 RendererFrameManager::GetInstance()->set_max_handles( |
| 2175 base::SharedMemory::GetHandleLimit()); | 2325 base::SharedMemory::GetHandleLimit()); |
| 2176 | 2326 |
| 2177 for (size_t i = 0; i < renderer_count; ++i) { | 2327 for (size_t i = 0; i < renderer_count; ++i) { |
| 2178 views[i]->Destroy(); | 2328 views[i]->Destroy(); |
| 2179 delete hosts[i]; | 2329 delete hosts[i]; |
| 2180 } | 2330 } |
| 2181 } | 2331 } |
| 2182 | 2332 |
| 2183 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { | 2333 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithLocking) { |
| 2184 view_->InitAsChild(NULL); | 2334 view_->InitAsChild(nullptr); |
| 2185 | 2335 |
| 2186 size_t max_renderer_frames = | 2336 size_t max_renderer_frames = |
| 2187 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); | 2337 RendererFrameManager::GetInstance()->GetMaxNumberOfSavedFrames(); |
| 2188 ASSERT_LE(2u, max_renderer_frames); | 2338 ASSERT_LE(2u, max_renderer_frames); |
| 2189 size_t renderer_count = max_renderer_frames + 1; | 2339 size_t renderer_count = max_renderer_frames + 1; |
| 2190 gfx::Rect view_rect(100, 100); | 2340 gfx::Rect view_rect(100, 100); |
| 2191 gfx::Size frame_size = view_rect.size(); | 2341 gfx::Size frame_size = view_rect.size(); |
| 2192 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2342 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
| 2193 | 2343 |
| 2194 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2344 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
| 2195 new RenderWidgetHostImpl*[renderer_count]); | 2345 new RenderWidgetHostImpl*[renderer_count]); |
| 2196 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2346 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
| 2197 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2347 new FakeRenderWidgetHostViewAura*[renderer_count]); |
| 2198 | 2348 |
| 2199 // Create a bunch of renderers. | 2349 // Create a bunch of renderers. |
| 2200 for (size_t i = 0; i < renderer_count; ++i) { | 2350 for (size_t i = 0; i < renderer_count; ++i) { |
| 2201 int32_t routing_id = process_host_->GetNextRoutingID(); | 2351 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 2202 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2352 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 2203 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, | 2353 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, |
| 2204 routing_id, false); | 2354 routing_id, false); |
| 2205 delegates_.back()->set_widget_host(hosts[i]); | 2355 delegates_.back()->set_widget_host(hosts[i]); |
| 2206 hosts[i]->Init(); | 2356 hosts[i]->Init(); |
| 2207 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); | 2357 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); |
| 2208 views[i]->InitAsChild(NULL); | 2358 views[i]->InitAsChild(nullptr); |
| 2209 aura::client::ParentWindowWithContext( | 2359 aura::client::ParentWindowWithContext( |
| 2210 views[i]->GetNativeView(), | 2360 views[i]->GetNativeView(), |
| 2211 parent_view_->GetNativeView()->GetRootWindow(), | 2361 parent_view_->GetNativeView()->GetRootWindow(), |
| 2212 gfx::Rect()); | 2362 gfx::Rect()); |
| 2213 views[i]->SetSize(view_rect.size()); | 2363 views[i]->SetSize(view_rect.size()); |
| 2214 } | 2364 } |
| 2215 | 2365 |
| 2216 // Make each renderer visible and swap a frame on it. No eviction should | 2366 // Make each renderer visible and swap a frame on it. No eviction should |
| 2217 // occur because all frames are visible. | 2367 // occur because all frames are visible. |
| 2218 for (size_t i = 0; i < renderer_count; ++i) { | 2368 for (size_t i = 0; i < renderer_count; ++i) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2241 | 2391 |
| 2242 for (size_t i = 0; i < renderer_count; ++i) { | 2392 for (size_t i = 0; i < renderer_count; ++i) { |
| 2243 views[i]->Destroy(); | 2393 views[i]->Destroy(); |
| 2244 delete hosts[i]; | 2394 delete hosts[i]; |
| 2245 } | 2395 } |
| 2246 } | 2396 } |
| 2247 | 2397 |
| 2248 // Test that changing the memory pressure should delete saved frames. This test | 2398 // Test that changing the memory pressure should delete saved frames. This test |
| 2249 // only applies to ChromeOS. | 2399 // only applies to ChromeOS. |
| 2250 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) { | 2400 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) { |
| 2251 view_->InitAsChild(NULL); | 2401 view_->InitAsChild(nullptr); |
| 2252 | 2402 |
| 2253 // The test logic below relies on having max_renderer_frames > 2. By default, | 2403 // The test logic below relies on having max_renderer_frames > 2. By default, |
| 2254 // this value is calculated from total physical memory and causes the test to | 2404 // this value is calculated from total physical memory and causes the test to |
| 2255 // fail when run on hardware with < 256MB of RAM. | 2405 // fail when run on hardware with < 256MB of RAM. |
| 2256 const size_t kMaxRendererFrames = 5; | 2406 const size_t kMaxRendererFrames = 5; |
| 2257 RendererFrameManager::GetInstance()->set_max_number_of_saved_frames( | 2407 RendererFrameManager::GetInstance()->set_max_number_of_saved_frames( |
| 2258 kMaxRendererFrames); | 2408 kMaxRendererFrames); |
| 2259 | 2409 |
| 2260 size_t renderer_count = kMaxRendererFrames; | 2410 size_t renderer_count = kMaxRendererFrames; |
| 2261 gfx::Rect view_rect(100, 100); | 2411 gfx::Rect view_rect(100, 100); |
| 2262 gfx::Size frame_size = view_rect.size(); | 2412 gfx::Size frame_size = view_rect.size(); |
| 2263 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); | 2413 DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); |
| 2264 | 2414 |
| 2265 std::unique_ptr<RenderWidgetHostImpl* []> hosts( | 2415 std::unique_ptr<RenderWidgetHostImpl* []> hosts( |
| 2266 new RenderWidgetHostImpl*[renderer_count]); | 2416 new RenderWidgetHostImpl*[renderer_count]); |
| 2267 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( | 2417 std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( |
| 2268 new FakeRenderWidgetHostViewAura*[renderer_count]); | 2418 new FakeRenderWidgetHostViewAura*[renderer_count]); |
| 2269 | 2419 |
| 2270 // Create a bunch of renderers. | 2420 // Create a bunch of renderers. |
| 2271 for (size_t i = 0; i < renderer_count; ++i) { | 2421 for (size_t i = 0; i < renderer_count; ++i) { |
| 2272 int32_t routing_id = process_host_->GetNextRoutingID(); | 2422 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 2273 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); | 2423 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); |
| 2274 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, | 2424 hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, |
| 2275 routing_id, false); | 2425 routing_id, false); |
| 2276 delegates_.back()->set_widget_host(hosts[i]); | 2426 delegates_.back()->set_widget_host(hosts[i]); |
| 2277 hosts[i]->Init(); | 2427 hosts[i]->Init(); |
| 2278 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); | 2428 views[i] = new FakeRenderWidgetHostViewAura(hosts[i], false); |
| 2279 views[i]->InitAsChild(NULL); | 2429 views[i]->InitAsChild(nullptr); |
| 2280 aura::client::ParentWindowWithContext( | 2430 aura::client::ParentWindowWithContext( |
| 2281 views[i]->GetNativeView(), | 2431 views[i]->GetNativeView(), |
| 2282 parent_view_->GetNativeView()->GetRootWindow(), | 2432 parent_view_->GetNativeView()->GetRootWindow(), |
| 2283 gfx::Rect()); | 2433 gfx::Rect()); |
| 2284 views[i]->SetSize(view_rect.size()); | 2434 views[i]->SetSize(view_rect.size()); |
| 2285 } | 2435 } |
| 2286 | 2436 |
| 2287 // Make each renderer visible and swap a frame on it. No eviction should | 2437 // Make each renderer visible and swap a frame on it. No eviction should |
| 2288 // occur because all frames are visible. | 2438 // occur because all frames are visible. |
| 2289 for (size_t i = 0; i < renderer_count; ++i) { | 2439 for (size_t i = 0; i < renderer_count; ++i) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2315 for (size_t i = 0; i < renderer_count; ++i) { | 2465 for (size_t i = 0; i < renderer_count; ++i) { |
| 2316 views[i]->Destroy(); | 2466 views[i]->Destroy(); |
| 2317 delete hosts[i]; | 2467 delete hosts[i]; |
| 2318 } | 2468 } |
| 2319 } | 2469 } |
| 2320 | 2470 |
| 2321 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) { | 2471 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) { |
| 2322 gfx::Rect view_rect(100, 100); | 2472 gfx::Rect view_rect(100, 100); |
| 2323 gfx::Size frame_size(100, 100); | 2473 gfx::Size frame_size(100, 100); |
| 2324 | 2474 |
| 2325 view_->InitAsChild(NULL); | 2475 view_->InitAsChild(nullptr); |
| 2326 aura::client::ParentWindowWithContext( | 2476 aura::client::ParentWindowWithContext( |
| 2327 view_->GetNativeView(), | 2477 view_->GetNativeView(), |
| 2328 parent_view_->GetNativeView()->GetRootWindow(), | 2478 parent_view_->GetNativeView()->GetRootWindow(), |
| 2329 gfx::Rect()); | 2479 gfx::Rect()); |
| 2330 view_->SetSize(view_rect.size()); | 2480 view_->SetSize(view_rect.size()); |
| 2331 view_->Show(); | 2481 view_->Show(); |
| 2332 | 2482 |
| 2333 // With a 1x DPI UI and 1x DPI Renderer. | 2483 // With a 1x DPI UI and 1x DPI Renderer. |
| 2334 view_->OnSwapCompositorFrame( | 2484 view_->OnSwapCompositorFrame( |
| 2335 1, MakeDelegatedFrame(1.f, frame_size, gfx::Rect(frame_size))); | 2485 1, MakeDelegatedFrame(1.f, frame_size, gfx::Rect(frame_size))); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2366 void RunLoopUntilCallback() { | 2516 void RunLoopUntilCallback() { |
| 2367 base::RunLoop run_loop; | 2517 base::RunLoop run_loop; |
| 2368 quit_closure_ = run_loop.QuitClosure(); | 2518 quit_closure_ = run_loop.QuitClosure(); |
| 2369 // Temporarily ignore real draw requests. | 2519 // Temporarily ignore real draw requests. |
| 2370 frame_subscriber_->set_should_capture(false); | 2520 frame_subscriber_->set_should_capture(false); |
| 2371 run_loop.Run(); | 2521 run_loop.Run(); |
| 2372 frame_subscriber_->set_should_capture(true); | 2522 frame_subscriber_->set_should_capture(true); |
| 2373 } | 2523 } |
| 2374 | 2524 |
| 2375 void InitializeView() { | 2525 void InitializeView() { |
| 2376 view_->InitAsChild(NULL); | 2526 view_->InitAsChild(nullptr); |
| 2377 view_->GetDelegatedFrameHost()->SetRequestCopyOfOutputCallbackForTesting( | 2527 view_->GetDelegatedFrameHost()->SetRequestCopyOfOutputCallbackForTesting( |
| 2378 base::Bind(&FakeRenderWidgetHostViewAura::InterceptCopyOfOutput, | 2528 base::Bind(&FakeRenderWidgetHostViewAura::InterceptCopyOfOutput, |
| 2379 base::Unretained(view_))); | 2529 base::Unretained(view_))); |
| 2380 aura::client::ParentWindowWithContext( | 2530 aura::client::ParentWindowWithContext( |
| 2381 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), | 2531 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), |
| 2382 gfx::Rect()); | 2532 gfx::Rect()); |
| 2383 view_->SetSize(view_rect_.size()); | 2533 view_->SetSize(view_rect_.size()); |
| 2384 view_->Show(); | 2534 view_->Show(); |
| 2385 | 2535 |
| 2386 frame_subscriber_ = new FakeFrameSubscriber( | 2536 frame_subscriber_ = new FakeFrameSubscriber( |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 EXPECT_EQ(kBaseTime + kDefaultInterval * std::ceil(kElapsedIntervals), | 2744 EXPECT_EQ(kBaseTime + kDefaultInterval * std::ceil(kElapsedIntervals), |
| 2595 frame_subscriber_->last_present_time()); | 2745 frame_subscriber_->last_present_time()); |
| 2596 | 2746 |
| 2597 // Destroy the RenderWidgetHostViewAura and ImageTransportFactory. | 2747 // Destroy the RenderWidgetHostViewAura and ImageTransportFactory. |
| 2598 TearDownEnvironment(); | 2748 TearDownEnvironment(); |
| 2599 } | 2749 } |
| 2600 | 2750 |
| 2601 TEST_F(RenderWidgetHostViewAuraTest, VisibleViewportTest) { | 2751 TEST_F(RenderWidgetHostViewAuraTest, VisibleViewportTest) { |
| 2602 gfx::Rect view_rect(100, 100); | 2752 gfx::Rect view_rect(100, 100); |
| 2603 | 2753 |
| 2604 view_->InitAsChild(NULL); | 2754 view_->InitAsChild(nullptr); |
| 2605 aura::client::ParentWindowWithContext( | 2755 aura::client::ParentWindowWithContext( |
| 2606 view_->GetNativeView(), | 2756 view_->GetNativeView(), |
| 2607 parent_view_->GetNativeView()->GetRootWindow(), | 2757 parent_view_->GetNativeView()->GetRootWindow(), |
| 2608 gfx::Rect()); | 2758 gfx::Rect()); |
| 2609 view_->SetSize(view_rect.size()); | 2759 view_->SetSize(view_rect.size()); |
| 2610 view_->Show(); | 2760 view_->Show(); |
| 2611 | 2761 |
| 2612 // Defaults to full height of the view. | 2762 // Defaults to full height of the view. |
| 2613 EXPECT_EQ(100, view_->GetVisibleViewportSize().height()); | 2763 EXPECT_EQ(100, view_->GetVisibleViewportSize().height()); |
| 2614 | 2764 |
| 2615 widget_host_->ResetSizeAndRepaintPendingFlags(); | 2765 widget_host_->ResetSizeAndRepaintPendingFlags(); |
| 2616 sink_->ClearMessages(); | 2766 sink_->ClearMessages(); |
| 2617 view_->SetInsets(gfx::Insets(0, 0, 40, 0)); | 2767 view_->SetInsets(gfx::Insets(0, 0, 40, 0)); |
| 2618 | 2768 |
| 2619 EXPECT_EQ(60, view_->GetVisibleViewportSize().height()); | 2769 EXPECT_EQ(60, view_->GetVisibleViewportSize().height()); |
| 2620 | 2770 |
| 2621 const IPC::Message *message = sink_->GetFirstMessageMatching( | 2771 const IPC::Message *message = sink_->GetFirstMessageMatching( |
| 2622 ViewMsg_Resize::ID); | 2772 ViewMsg_Resize::ID); |
| 2623 ASSERT_TRUE(message != NULL); | 2773 ASSERT_TRUE(message != nullptr); |
| 2624 | 2774 |
| 2625 ViewMsg_Resize::Param params; | 2775 ViewMsg_Resize::Param params; |
| 2626 ViewMsg_Resize::Read(message, ¶ms); | 2776 ViewMsg_Resize::Read(message, ¶ms); |
| 2627 EXPECT_EQ(60, std::get<0>(params).visible_viewport_size.height()); | 2777 EXPECT_EQ(60, std::get<0>(params).visible_viewport_size.height()); |
| 2628 } | 2778 } |
| 2629 | 2779 |
| 2630 // Ensures that touch event positions are never truncated to integers. | 2780 // Ensures that touch event positions are never truncated to integers. |
| 2631 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { | 2781 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { |
| 2632 const float kX = 30.58f; | 2782 const float kX = 30.58f; |
| 2633 const float kY = 50.23f; | 2783 const float kY = 50.23f; |
| 2634 | 2784 |
| 2635 view_->InitAsChild(NULL); | 2785 view_->InitAsChild(nullptr); |
| 2636 view_->Show(); | 2786 view_->Show(); |
| 2637 | 2787 |
| 2638 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(), 0, | 2788 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(), 0, |
| 2639 ui::EventTimeForNow()); | 2789 ui::EventTimeForNow()); |
| 2640 press.set_location_f(gfx::PointF(kX, kY)); | 2790 press.set_location_f(gfx::PointF(kX, kY)); |
| 2641 press.set_root_location_f(gfx::PointF(kX, kY)); | 2791 press.set_root_location_f(gfx::PointF(kX, kY)); |
| 2642 | 2792 |
| 2643 view_->OnTouchEvent(&press); | 2793 view_->OnTouchEvent(&press); |
| 2644 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); | 2794 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); |
| 2645 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 2795 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 // the host. | 3746 // the host. |
| 3597 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3747 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 3598 blink::WebGestureDeviceTouchscreen); | 3748 blink::WebGestureDeviceTouchscreen); |
| 3599 SimulateGestureScrollUpdateEvent(300, -5, 0); | 3749 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 3600 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 3750 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 3601 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3751 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3602 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 3752 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 3603 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3753 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 3604 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 3754 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
| 3605 | 3755 |
| 3606 view_->OnWindowFocused(NULL, view_->GetNativeView()); | 3756 view_->OnWindowFocused(nullptr, view_->GetNativeView()); |
| 3607 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3757 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3608 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3758 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3609 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 3759 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 3610 EXPECT_EQ(0.f, overscroll_delegate()->delta_x()); | 3760 EXPECT_EQ(0.f, overscroll_delegate()->delta_x()); |
| 3611 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 3761 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 3612 sink_->ClearMessages(); | 3762 sink_->ClearMessages(); |
| 3613 | 3763 |
| 3614 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 3764 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 3615 blink::WebGestureDeviceTouchscreen); | 3765 blink::WebGestureDeviceTouchscreen); |
| 3616 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3766 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3629 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 3779 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 3630 blink::WebGestureDeviceTouchscreen); | 3780 blink::WebGestureDeviceTouchscreen); |
| 3631 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3781 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3632 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3782 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3633 EXPECT_EQ(3U, sink_->message_count()); | 3783 EXPECT_EQ(3U, sink_->message_count()); |
| 3634 } | 3784 } |
| 3635 | 3785 |
| 3636 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 3786 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
| 3637 // before RWH), we clean up properly and don't leak the RWHVGuest. | 3787 // before RWH), we clean up properly and don't leak the RWHVGuest. |
| 3638 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 3788 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
| 3639 view_->InitAsChild(NULL); | 3789 view_->InitAsChild(nullptr); |
| 3640 TearDownEnvironment(); | 3790 TearDownEnvironment(); |
| 3641 ASSERT_FALSE(guest_view_weak_.get()); | 3791 ASSERT_FALSE(guest_view_weak_.get()); |
| 3642 } | 3792 } |
| 3643 | 3793 |
| 3644 // Tests that invalid touch events are consumed and handled | 3794 // Tests that invalid touch events are consumed and handled |
| 3645 // synchronously. | 3795 // synchronously. |
| 3646 TEST_F(RenderWidgetHostViewAuraTest, | 3796 TEST_F(RenderWidgetHostViewAuraTest, |
| 3647 InvalidEventsHaveSyncHandlingDisabled) { | 3797 InvalidEventsHaveSyncHandlingDisabled) { |
| 3648 view_->InitAsChild(NULL); | 3798 view_->InitAsChild(nullptr); |
| 3649 view_->Show(); | 3799 view_->Show(); |
| 3650 GetSentMessageCountAndResetSink(); | 3800 GetSentMessageCountAndResetSink(); |
| 3651 | 3801 |
| 3652 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 3802 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 3653 | 3803 |
| 3654 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 3804 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 3655 ui::EventTimeForNow()); | 3805 ui::EventTimeForNow()); |
| 3656 | 3806 |
| 3657 // Construct a move with a touch id which doesn't exist. | 3807 // Construct a move with a touch id which doesn't exist. |
| 3658 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | 3808 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
| 3659 ui::EventTimeForNow()); | 3809 ui::EventTimeForNow()); |
| 3660 | 3810 |
| 3661 // Valid press is handled asynchronously. | 3811 // Valid press is handled asynchronously. |
| 3662 view_->OnTouchEvent(&press); | 3812 view_->OnTouchEvent(&press); |
| 3663 EXPECT_TRUE(press.synchronous_handling_disabled()); | 3813 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 3664 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3814 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3665 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED); | 3815 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 3666 | 3816 |
| 3667 // Invalid move is handled synchronously, but is consumed. It should not | 3817 // Invalid move is handled synchronously, but is consumed. It should not |
| 3668 // be forwarded to the renderer. | 3818 // be forwarded to the renderer. |
| 3669 view_->OnTouchEvent(&invalid_move); | 3819 view_->OnTouchEvent(&invalid_move); |
| 3670 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 3820 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 3671 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); | 3821 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); |
| 3672 EXPECT_TRUE(invalid_move.stopped_propagation()); | 3822 EXPECT_TRUE(invalid_move.stopped_propagation()); |
| 3673 } | 3823 } |
| 3674 | 3824 |
| 3675 // Checks key event codes. | 3825 // Checks key event codes. |
| 3676 TEST_F(RenderWidgetHostViewAuraTest, KeyEvent) { | 3826 TEST_F(RenderWidgetHostViewAuraTest, KeyEvent) { |
| 3677 view_->InitAsChild(NULL); | 3827 view_->InitAsChild(nullptr); |
| 3678 view_->Show(); | 3828 view_->Show(); |
| 3679 | 3829 |
| 3680 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, | 3830 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, |
| 3681 ui::EF_NONE); | 3831 ui::EF_NONE); |
| 3682 view_->OnKeyEvent(&key_event); | 3832 view_->OnKeyEvent(&key_event); |
| 3683 | 3833 |
| 3684 const NativeWebKeyboardEvent* event = delegates_.back()->last_event(); | 3834 const NativeWebKeyboardEvent* event = delegates_.back()->last_event(); |
| 3685 EXPECT_NE(nullptr, event); | 3835 EXPECT_NE(nullptr, event); |
| 3686 if (event) { | 3836 if (event) { |
| 3687 EXPECT_EQ(key_event.key_code(), event->windowsKeyCode); | 3837 EXPECT_EQ(key_event.key_code(), event->windowsKeyCode); |
| 3688 EXPECT_EQ(ui::KeycodeConverter::DomCodeToNativeKeycode(key_event.code()), | 3838 EXPECT_EQ(ui::KeycodeConverter::DomCodeToNativeKeycode(key_event.code()), |
| 3689 event->nativeKeyCode); | 3839 event->nativeKeyCode); |
| 3690 } | 3840 } |
| 3691 } | 3841 } |
| 3692 | 3842 |
| 3693 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { | 3843 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { |
| 3694 view_->InitAsChild(NULL); | 3844 view_->InitAsChild(nullptr); |
| 3695 view_->Show(); | 3845 view_->Show(); |
| 3696 | 3846 |
| 3697 sink_->ClearMessages(); | 3847 sink_->ClearMessages(); |
| 3698 | 3848 |
| 3699 // Simulates the mouse wheel event with ctrl modifier applied. | 3849 // Simulates the mouse wheel event with ctrl modifier applied. |
| 3700 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), | 3850 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), |
| 3701 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0); | 3851 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0); |
| 3702 view_->OnMouseEvent(&event); | 3852 view_->OnMouseEvent(&event); |
| 3703 | 3853 |
| 3704 const WebInputEvent* input_event = | 3854 const WebInputEvent* input_event = |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3864 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to | 4014 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to |
| 3865 // the renderer process. | 4015 // the renderer process. |
| 3866 TEST_F(RenderWidgetHostViewAuraTest, SurfaceClientIdInitialized) { | 4016 TEST_F(RenderWidgetHostViewAuraTest, SurfaceClientIdInitialized) { |
| 3867 gfx::Size size(5, 5); | 4017 gfx::Size size(5, 5); |
| 3868 | 4018 |
| 3869 const IPC::Message* msg = | 4019 const IPC::Message* msg = |
| 3870 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceClientId::ID); | 4020 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceClientId::ID); |
| 3871 EXPECT_TRUE(msg); | 4021 EXPECT_TRUE(msg); |
| 3872 ViewMsg_SetSurfaceClientId::Param params; | 4022 ViewMsg_SetSurfaceClientId::Param params; |
| 3873 ViewMsg_SetSurfaceClientId::Read(msg, ¶ms); | 4023 ViewMsg_SetSurfaceClientId::Read(msg, ¶ms); |
| 3874 view_->InitAsChild(NULL); | 4024 view_->InitAsChild(nullptr); |
| 3875 view_->Show(); | 4025 view_->Show(); |
| 3876 view_->SetSize(size); | 4026 view_->SetSize(size); |
| 3877 view_->OnSwapCompositorFrame(0, | 4027 view_->OnSwapCompositorFrame(0, |
| 3878 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 4028 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
| 3879 EXPECT_EQ(view_->GetSurfaceClientId(), std::get<0>(params)); | 4029 EXPECT_EQ(view_->GetSurfaceClientId(), std::get<0>(params)); |
| 3880 } | 4030 } |
| 3881 | 4031 |
| 3882 // This class provides functionality to test a RenderWidgetHostViewAura | 4032 // This class provides functionality to test a RenderWidgetHostViewAura |
| 3883 // instance which has been hooked up to a test RenderViewHost instance and | 4033 // instance which has been hooked up to a test RenderViewHost instance and |
| 3884 // a WebContents instance. | 4034 // a WebContents instance. |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4316 // No bounds at index 1. | 4466 // No bounds at index 1. |
| 4317 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound)); | 4467 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound)); |
| 4318 | 4468 |
| 4319 // Valid bound at index 0. | 4469 // Valid bound at index 0. |
| 4320 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound)); | 4470 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound)); |
| 4321 EXPECT_EQ(4 + (int)index, bound.height()); | 4471 EXPECT_EQ(4 + (int)index, bound.height()); |
| 4322 } | 4472 } |
| 4323 } | 4473 } |
| 4324 | 4474 |
| 4325 } // namespace content | 4475 } // namespace content |
| OLD | NEW |