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

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

Issue 113923006: Strips leading and trailing whitespace from tooltip (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unused code Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/corewm/tooltip_controller.cc ('k') | no next file » | 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/aura/client/cursor_client.h" 8 #include "ui/aura/client/cursor_client.h"
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/client/tooltip_client.h" 10 #include "ui/aura/client/tooltip_client.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/aura/test/aura_test_base.h" 13 #include "ui/aura/test/aura_test_base.h"
14 #include "ui/aura/test/event_generator.h" 14 #include "ui/aura/test/event_generator.h"
15 #include "ui/aura/test/test_screen.h" 15 #include "ui/aura/test/test_screen.h"
16 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/font.h" 19 #include "ui/gfx/font.h"
19 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
20 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
21 #include "ui/gfx/screen_type_delegate.h" 22 #include "ui/gfx/screen_type_delegate.h"
22 #include "ui/gfx/text_elider.h" 23 #include "ui/gfx/text_elider.h"
23 #include "ui/views/corewm/tooltip_aura.h" 24 #include "ui/views/corewm/tooltip_aura.h"
24 #include "ui/views/corewm/tooltip_controller_test_helper.h" 25 #include "ui/views/corewm/tooltip_controller_test_helper.h"
25 #include "ui/views/corewm/wm_state.h" 26 #include "ui/views/corewm/wm_state.h"
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 647
647 native_widget->HandleActivationChanged(false); 648 native_widget->HandleActivationChanged(false);
648 native_widget->HandleActivationChanged(true); 649 native_widget->HandleActivationChanged(true);
649 650
650 EXPECT_EQ( 651 EXPECT_EQ(
651 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), 652 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(),
652 ui::wm::WINDOW_TYPE_TOOLTIP); 653 ui::wm::WINDOW_TYPE_TOOLTIP);
653 } 654 }
654 #endif 655 #endif
655 656
657 namespace {
658
659 class TestTooltip : public Tooltip {
660 public:
661 TestTooltip() : is_visible_(false) {}
662 virtual ~TestTooltip() {}
663
664 const base::string16& tooltip_text() const { return tooltip_text_; }
665
666 // Tooltip:
667 virtual void SetText(aura::Window* window,
668 const base::string16& tooltip_text,
669 const gfx::Point& location) OVERRIDE {
670 tooltip_text_ = tooltip_text;
671 }
672 virtual void Show() OVERRIDE {
673 is_visible_ = true;
674 }
675 virtual void Hide() OVERRIDE {
676 is_visible_ = false;
677 }
678 virtual bool IsVisible() OVERRIDE {
679 return is_visible_;
680 }
681
682 private:
683 bool is_visible_;
684 base::string16 tooltip_text_;
685
686 DISALLOW_COPY_AND_ASSIGN(TestTooltip);
687 };
688
689 } // namespace
690
691 // Use for tests that don't depend upon views.
692 class TooltipControllerTest2 : public aura::test::AuraTestBase {
693 public:
694 TooltipControllerTest2() : test_tooltip_(new TestTooltip) {}
695 virtual ~TooltipControllerTest2() {}
696
697 virtual void SetUp() OVERRIDE {
698 wm_state_.reset(new views::corewm::WMState);
699 aura::test::AuraTestBase::SetUp();
700 controller_.reset(new TooltipController(
701 scoped_ptr<views::corewm::Tooltip>(test_tooltip_)));
702 root_window()->AddPreTargetHandler(controller_.get());
703 SetTooltipClient(root_window(), controller_.get());
704 helper_.reset(new TooltipControllerTestHelper(controller_.get()));
705 generator_.reset(new aura::test::EventGenerator(root_window()));
706 }
707
708 virtual void TearDown() OVERRIDE {
709 root_window()->RemovePreTargetHandler(controller_.get());
710 aura::client::SetTooltipClient(root_window(), NULL);
711 controller_.reset();
712 generator_.reset();
713 helper_.reset();
714 aura::test::AuraTestBase::TearDown();
715 wm_state_.reset();
716 }
717
718 protected:
719 // Owned by |controller_|.
720 TestTooltip* test_tooltip_;
721 scoped_ptr<TooltipControllerTestHelper> helper_;
722 scoped_ptr<aura::test::EventGenerator> generator_;
723
724 private:
725 scoped_ptr<TooltipController> controller_;
726 scoped_ptr<views::corewm::WMState> wm_state_;
727
728 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2);
729 };
730
731 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) {
732 aura::test::TestWindowDelegate test_delegate;
733 scoped_ptr<aura::Window> window(
734 CreateNormalWindow(100, root_window(), &test_delegate));
735 window->SetBounds(gfx::Rect(0, 0, 300, 300));
736 base::string16 tooltip_text(ASCIIToUTF16(" \nx "));
737 aura::client::SetTooltipText(window.get(), &tooltip_text);
738 generator_->MoveMouseToCenterOf(window.get());
739 helper_->FireTooltipTimer();
740 EXPECT_EQ(ASCIIToUTF16("x"), test_tooltip_->tooltip_text());
741 }
742
656 } // namespace test 743 } // namespace test
657 } // namespace corewm 744 } // namespace corewm
658 } // namespace views 745 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/tooltip_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698