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

Side by Side Diff: ui/views/corewm/tooltip_controller_unittest.cc

Issue 2453953003: Moves TransientWindowClient to ui/aura/client and adds observer (Closed)
Patch Set: merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/test/aura_test_helper.cc ('k') | ui/views/test/test_views_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/views/corewm/tooltip_controller.h" 5 #include "ui/views/corewm/tooltip_controller.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/views/corewm/tooltip_controller_test_helper.h" 24 #include "ui/views/corewm/tooltip_controller_test_helper.h"
25 #include "ui/views/test/desktop_test_views_delegate.h" 25 #include "ui/views/test/desktop_test_views_delegate.h"
26 #include "ui/views/test/native_widget_factory.h" 26 #include "ui/views/test/native_widget_factory.h"
27 #include "ui/views/test/test_views_delegate.h" 27 #include "ui/views/test/test_views_delegate.h"
28 #include "ui/views/test/views_test_base.h" 28 #include "ui/views/test/views_test_base.h"
29 #include "ui/views/view.h" 29 #include "ui/views/view.h"
30 #include "ui/views/widget/tooltip_manager.h" 30 #include "ui/views/widget/tooltip_manager.h"
31 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
32 #include "ui/wm/core/default_activation_client.h" 32 #include "ui/wm/core/default_activation_client.h"
33 #include "ui/wm/core/default_screen_position_client.h" 33 #include "ui/wm/core/default_screen_position_client.h"
34 #include "ui/wm/core/wm_state.h"
35 #include "ui/wm/public/tooltip_client.h" 34 #include "ui/wm/public/tooltip_client.h"
36 #include "ui/wm/public/window_types.h" 35 #include "ui/wm/public/window_types.h"
37 36
38 #if defined(OS_WIN) 37 #if defined(OS_WIN)
39 #include "ui/base/win/scoped_ole_initializer.h" 38 #include "ui/base/win/scoped_ole_initializer.h"
40 #endif 39 #endif
41 40
42 #if !defined(OS_CHROMEOS) 41 #if !defined(OS_CHROMEOS)
43 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 42 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
44 #include "ui/views/widget/desktop_aura/desktop_screen.h" 43 #include "ui/views/widget/desktop_aura/desktop_screen.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 565
567 } // namespace 566 } // namespace
568 567
569 // Use for tests that don't depend upon views. 568 // Use for tests that don't depend upon views.
570 class TooltipControllerTest2 : public aura::test::AuraTestBase { 569 class TooltipControllerTest2 : public aura::test::AuraTestBase {
571 public: 570 public:
572 TooltipControllerTest2() : test_tooltip_(new TestTooltip) {} 571 TooltipControllerTest2() : test_tooltip_(new TestTooltip) {}
573 ~TooltipControllerTest2() override {} 572 ~TooltipControllerTest2() override {}
574 573
575 void SetUp() override { 574 void SetUp() override {
576 wm_state_.reset(new wm::WMState);
577 aura::test::AuraTestBase::SetUp(); 575 aura::test::AuraTestBase::SetUp();
578 new wm::DefaultActivationClient(root_window()); 576 new wm::DefaultActivationClient(root_window());
579 controller_.reset( 577 controller_.reset(
580 new TooltipController(std::unique_ptr<corewm::Tooltip>(test_tooltip_))); 578 new TooltipController(std::unique_ptr<corewm::Tooltip>(test_tooltip_)));
581 root_window()->AddPreTargetHandler(controller_.get()); 579 root_window()->AddPreTargetHandler(controller_.get());
582 SetTooltipClient(root_window(), controller_.get()); 580 SetTooltipClient(root_window(), controller_.get());
583 helper_.reset(new TooltipControllerTestHelper(controller_.get())); 581 helper_.reset(new TooltipControllerTestHelper(controller_.get()));
584 generator_.reset(new ui::test::EventGenerator(root_window())); 582 generator_.reset(new ui::test::EventGenerator(root_window()));
585 } 583 }
586 584
587 void TearDown() override { 585 void TearDown() override {
588 root_window()->RemovePreTargetHandler(controller_.get()); 586 root_window()->RemovePreTargetHandler(controller_.get());
589 aura::client::SetTooltipClient(root_window(), NULL); 587 aura::client::SetTooltipClient(root_window(), NULL);
590 controller_.reset(); 588 controller_.reset();
591 generator_.reset(); 589 generator_.reset();
592 helper_.reset(); 590 helper_.reset();
593 aura::test::AuraTestBase::TearDown(); 591 aura::test::AuraTestBase::TearDown();
594 wm_state_.reset();
595 } 592 }
596 593
597 protected: 594 protected:
598 // Owned by |controller_|. 595 // Owned by |controller_|.
599 TestTooltip* test_tooltip_; 596 TestTooltip* test_tooltip_;
600 std::unique_ptr<TooltipControllerTestHelper> helper_; 597 std::unique_ptr<TooltipControllerTestHelper> helper_;
601 std::unique_ptr<ui::test::EventGenerator> generator_; 598 std::unique_ptr<ui::test::EventGenerator> generator_;
602 599
603 private: 600 private:
604 std::unique_ptr<TooltipController> controller_; 601 std::unique_ptr<TooltipController> controller_;
605 std::unique_ptr<wm::WMState> wm_state_;
606 602
607 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2); 603 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2);
608 }; 604 };
609 605
610 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) { 606 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) {
611 aura::test::TestWindowDelegate test_delegate; 607 aura::test::TestWindowDelegate test_delegate;
612 std::unique_ptr<aura::Window> window( 608 std::unique_ptr<aura::Window> window(
613 CreateNormalWindow(100, root_window(), &test_delegate)); 609 CreateNormalWindow(100, root_window(), &test_delegate));
614 window->SetBounds(gfx::Rect(0, 0, 300, 300)); 610 window->SetBounds(gfx::Rect(0, 0, 300, 300));
615 base::string16 tooltip_text(ASCIIToUTF16(" \nx ")); 611 base::string16 tooltip_text(ASCIIToUTF16(" \nx "));
(...skipping 25 matching lines...) Expand all
641 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); 637 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL);
642 } 638 }
643 639
644 // Use for tests that need both views and a TestTooltip. 640 // Use for tests that need both views and a TestTooltip.
645 class TooltipControllerTest3 : public ViewsTestBase { 641 class TooltipControllerTest3 : public ViewsTestBase {
646 public: 642 public:
647 TooltipControllerTest3() : test_tooltip_(new TestTooltip) {} 643 TooltipControllerTest3() : test_tooltip_(new TestTooltip) {}
648 ~TooltipControllerTest3() override {} 644 ~TooltipControllerTest3() override {}
649 645
650 void SetUp() override { 646 void SetUp() override {
651 wm_state_.reset(new wm::WMState);
652 ViewsTestBase::SetUp(); 647 ViewsTestBase::SetUp();
653 648
654 aura::Window* root_window = GetContext(); 649 aura::Window* root_window = GetContext();
655 new wm::DefaultActivationClient(root_window); 650 new wm::DefaultActivationClient(root_window);
656 651
657 widget_.reset(CreateWidget(root_window)); 652 widget_.reset(CreateWidget(root_window));
658 widget_->SetContentsView(new View); 653 widget_->SetContentsView(new View);
659 view_ = new TooltipTestView; 654 view_ = new TooltipTestView;
660 widget_->GetContentsView()->AddChildView(view_); 655 widget_->GetContentsView()->AddChildView(view_);
661 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds()); 656 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds());
(...skipping 11 matching lines...) Expand all
673 668
674 void TearDown() override { 669 void TearDown() override {
675 GetRootWindow()->RemovePreTargetHandler(controller_.get()); 670 GetRootWindow()->RemovePreTargetHandler(controller_.get());
676 aura::client::SetTooltipClient(GetRootWindow(), NULL); 671 aura::client::SetTooltipClient(GetRootWindow(), NULL);
677 672
678 controller_.reset(); 673 controller_.reset();
679 generator_.reset(); 674 generator_.reset();
680 helper_.reset(); 675 helper_.reset();
681 widget_.reset(); 676 widget_.reset();
682 ViewsTestBase::TearDown(); 677 ViewsTestBase::TearDown();
683 wm_state_.reset();
684 } 678 }
685 679
686 aura::Window* GetWindow() { return widget_->GetNativeWindow(); } 680 aura::Window* GetWindow() { return widget_->GetNativeWindow(); }
687 681
688 protected: 682 protected:
689 // Owned by |controller_|. 683 // Owned by |controller_|.
690 TestTooltip* test_tooltip_; 684 TestTooltip* test_tooltip_;
691 std::unique_ptr<TooltipControllerTestHelper> helper_; 685 std::unique_ptr<TooltipControllerTestHelper> helper_;
692 std::unique_ptr<ui::test::EventGenerator> generator_; 686 std::unique_ptr<ui::test::EventGenerator> generator_;
693 std::unique_ptr<views::Widget> widget_; 687 std::unique_ptr<views::Widget> widget_;
694 TooltipTestView* view_; 688 TooltipTestView* view_;
695 689
696 private: 690 private:
697 std::unique_ptr<TooltipController> controller_; 691 std::unique_ptr<TooltipController> controller_;
698 std::unique_ptr<wm::WMState> wm_state_;
699 692
700 #if defined(OS_WIN) 693 #if defined(OS_WIN)
701 ui::ScopedOleInitializer ole_initializer_; 694 ui::ScopedOleInitializer ole_initializer_;
702 #endif 695 #endif
703 696
704 aura::Window* GetRootWindow() { return GetWindow()->GetRootWindow(); } 697 aura::Window* GetRootWindow() { return GetWindow()->GetRootWindow(); }
705 698
706 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest3); 699 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest3);
707 }; 700 };
708 701
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 helper_->FireTooltipTimer(); 800 helper_->FireTooltipTimer();
808 tooltip_bounds1 = test_tooltip_->location(); 801 tooltip_bounds1 = test_tooltip_->location();
809 802
810 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); 803 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1);
811 EXPECT_EQ(reference_string, helper_->GetTooltipText()); 804 EXPECT_EQ(reference_string, helper_->GetTooltipText());
812 } 805 }
813 806
814 } // namespace test 807 } // namespace test
815 } // namespace corewm 808 } // namespace corewm
816 } // namespace views 809 } // namespace views
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_helper.cc ('k') | ui/views/test/test_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698