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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 return nullptr; | 482 return nullptr; |
483 return reinterpret_cast<const WebInputEvent*>(data); | 483 return reinterpret_cast<const WebInputEvent*>(data); |
484 } | 484 } |
485 | 485 |
486 } // namespace | 486 } // namespace |
487 | 487 |
488 class RenderWidgetHostViewAuraTest : public testing::Test { | 488 class RenderWidgetHostViewAuraTest : public testing::Test { |
489 public: | 489 public: |
490 RenderWidgetHostViewAuraTest() | 490 RenderWidgetHostViewAuraTest() |
491 : widget_host_uses_shutdown_to_destroy_(false), | 491 : widget_host_uses_shutdown_to_destroy_(false), |
492 is_guest_view_hack_(false), | 492 is_guest_view_hack_(false) {} |
493 browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} | |
494 | 493 |
495 void SetUpEnvironment() { | 494 void SetUpEnvironment() { |
496 ImageTransportFactory::InitializeForUnitTests( | 495 ImageTransportFactory::InitializeForUnitTests( |
497 std::unique_ptr<ImageTransportFactory>( | 496 std::unique_ptr<ImageTransportFactory>( |
498 new NoTransportImageTransportFactory)); | 497 new NoTransportImageTransportFactory)); |
499 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 498 aura_test_helper_.reset( |
| 499 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
500 aura_test_helper_->SetUp( | 500 aura_test_helper_->SetUp( |
501 ImageTransportFactory::GetInstance()->GetContextFactory()); | 501 ImageTransportFactory::GetInstance()->GetContextFactory()); |
502 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 502 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
503 | 503 |
504 browser_context_.reset(new TestBrowserContext); | 504 browser_context_.reset(new TestBrowserContext); |
505 process_host_ = new MockRenderProcessHost(browser_context_.get()); | 505 process_host_ = new MockRenderProcessHost(browser_context_.get()); |
506 process_host_->Init(); | 506 process_host_->Init(); |
507 | 507 |
508 sink_ = &process_host_->sink(); | 508 sink_ = &process_host_->sink(); |
509 | 509 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 widget_host_->ShutdownAndDestroyWidget(true); | 546 widget_host_->ShutdownAndDestroyWidget(true); |
547 else | 547 else |
548 delete widget_host_; | 548 delete widget_host_; |
549 | 549 |
550 parent_view_->Destroy(); | 550 parent_view_->Destroy(); |
551 delete parent_host_; | 551 delete parent_host_; |
552 | 552 |
553 browser_context_.reset(); | 553 browser_context_.reset(); |
554 aura_test_helper_->TearDown(); | 554 aura_test_helper_->TearDown(); |
555 | 555 |
556 message_loop_.task_runner()->DeleteSoon(FROM_HERE, | |
557 browser_context_.release()); | |
558 base::RunLoop().RunUntilIdle(); | 556 base::RunLoop().RunUntilIdle(); |
559 ImageTransportFactory::Terminate(); | 557 ImageTransportFactory::Terminate(); |
560 } | 558 } |
561 | 559 |
562 void SetUp() override { SetUpEnvironment(); } | 560 void SetUp() override { SetUpEnvironment(); } |
563 | 561 |
564 void TearDown() override { TearDownEnvironment(); } | 562 void TearDown() override { TearDownEnvironment(); } |
565 | 563 |
566 void set_widget_host_uses_shutdown_to_destroy(bool use) { | 564 void set_widget_host_uses_shutdown_to_destroy(bool use) { |
567 widget_host_uses_shutdown_to_destroy_ = use; | 565 widget_host_uses_shutdown_to_destroy_ = use; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 TextInputState state_with_type_text; | 659 TextInputState state_with_type_text; |
662 state_with_type_text.type = type; | 660 state_with_type_text.type = type; |
663 view->TextInputStateChanged(state_with_type_text); | 661 view->TextInputStateChanged(state_with_type_text); |
664 } | 662 } |
665 | 663 |
666 // If true, then calls RWH::Shutdown() instead of deleting RWH. | 664 // If true, then calls RWH::Shutdown() instead of deleting RWH. |
667 bool widget_host_uses_shutdown_to_destroy_; | 665 bool widget_host_uses_shutdown_to_destroy_; |
668 | 666 |
669 bool is_guest_view_hack_; | 667 bool is_guest_view_hack_; |
670 | 668 |
671 base::MessageLoopForUI message_loop_; | 669 TestBrowserThreadBundle thread_bundle_; |
672 BrowserThreadImpl browser_thread_for_ui_; | |
673 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 670 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
674 std::unique_ptr<BrowserContext> browser_context_; | 671 std::unique_ptr<BrowserContext> browser_context_; |
675 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; | 672 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; |
676 MockRenderProcessHost* process_host_; | 673 MockRenderProcessHost* process_host_; |
677 | 674 |
678 // Tests should set these to nullptr if they've already triggered their | 675 // Tests should set these to nullptr if they've already triggered their |
679 // destruction. | 676 // destruction. |
680 RenderWidgetHostImpl* parent_host_; | 677 RenderWidgetHostImpl* parent_host_; |
681 RenderWidgetHostViewAura* parent_view_; | 678 RenderWidgetHostViewAura* parent_view_; |
682 | 679 |
(...skipping 4006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 | 4686 |
4690 // Retrieve the selected text from clipboard and verify it is as expected. | 4687 // Retrieve the selected text from clipboard and verify it is as expected. |
4691 base::string16 result_text; | 4688 base::string16 result_text; |
4692 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); | 4689 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); |
4693 EXPECT_EQ(expected_text, result_text); | 4690 EXPECT_EQ(expected_text, result_text); |
4694 } | 4691 } |
4695 } | 4692 } |
4696 #endif | 4693 #endif |
4697 | 4694 |
4698 } // namespace content | 4695 } // namespace content |
OLD | NEW |