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

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

Issue 2556083002: Don't subtract border from max size for display rect. (Closed)
Patch Set: RenderTextTestApi Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // TODO: these tests use GetContext(). That should go away for aura-mus 87 // TODO: these tests use GetContext(). That should go away for aura-mus
88 // client. http://crbug.com/663781. 88 // client. http://crbug.com/663781.
89 if (IsAuraMusClient()) 89 if (IsAuraMusClient())
90 return; 90 return;
91 91
92 aura::Window* root_window = GetContext(); 92 aura::Window* root_window = GetContext();
93 93
94 new wm::DefaultActivationClient(root_window); 94 new wm::DefaultActivationClient(root_window);
95 #if defined(OS_CHROMEOS) 95 #if defined(OS_CHROMEOS)
96 controller_.reset( 96 tooltip_aura_ = new views::corewm::TooltipAura();
97 new TooltipController(std::unique_ptr<views::corewm::Tooltip>( 97 controller_.reset(new TooltipController(
98 new views::corewm::TooltipAura))); 98 std::unique_ptr<views::corewm::Tooltip>(tooltip_aura_)));
99 root_window->AddPreTargetHandler(controller_.get()); 99 root_window->AddPreTargetHandler(controller_.get());
100 SetTooltipClient(root_window, controller_.get()); 100 SetTooltipClient(root_window, controller_.get());
101 #endif 101 #endif
102 widget_.reset(CreateWidget(root_window)); 102 widget_.reset(CreateWidget(root_window));
103 widget_->SetContentsView(new View); 103 widget_->SetContentsView(new View);
104 view_ = new TooltipTestView; 104 view_ = new TooltipTestView;
105 widget_->GetContentsView()->AddChildView(view_); 105 widget_->GetContentsView()->AddChildView(view_);
106 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds()); 106 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds());
107 helper_.reset(new TooltipControllerTestHelper( 107 helper_.reset(new TooltipControllerTestHelper(
108 GetController(widget_.get()))); 108 GetController(widget_.get())));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 view_->SetBounds(0, 0, 100, 100); 154 view_->SetBounds(0, 0, 100, 100);
155 view2->SetBounds(100, 0, 100, 100); 155 view2->SetBounds(100, 0, 100, 100);
156 return view2; 156 return view2;
157 } 157 }
158 158
159 std::unique_ptr<views::Widget> widget_; 159 std::unique_ptr<views::Widget> widget_;
160 TooltipTestView* view_; 160 TooltipTestView* view_;
161 std::unique_ptr<TooltipControllerTestHelper> helper_; 161 std::unique_ptr<TooltipControllerTestHelper> helper_;
162 std::unique_ptr<ui::test::EventGenerator> generator_; 162 std::unique_ptr<ui::test::EventGenerator> generator_;
163 163
164 protected:
165 #if defined(OS_CHROMEOS)
166 TooltipAura* tooltip_aura_; // not owned.
167 #endif
168
164 private: 169 private:
165 std::unique_ptr<TooltipController> controller_; 170 std::unique_ptr<TooltipController> controller_;
166 171
167 #if defined(OS_WIN) 172 #if defined(OS_WIN)
168 ui::ScopedOleInitializer ole_initializer_; 173 ui::ScopedOleInitializer ole_initializer_;
169 #endif 174 #endif
170 175
171 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest); 176 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest);
172 }; 177 };
173 178
(...skipping 18 matching lines...) Expand all
192 // Fire tooltip timer so tooltip becomes visible. 197 // Fire tooltip timer so tooltip becomes visible.
193 helper_->FireTooltipTimer(); 198 helper_->FireTooltipTimer();
194 199
195 EXPECT_TRUE(helper_->IsTooltipVisible()); 200 EXPECT_TRUE(helper_->IsTooltipVisible());
196 generator_->MoveMouseBy(1, 0); 201 generator_->MoveMouseBy(1, 0);
197 202
198 EXPECT_TRUE(helper_->IsTooltipVisible()); 203 EXPECT_TRUE(helper_->IsTooltipVisible());
199 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); 204 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow()));
200 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); 205 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText());
201 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); 206 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow());
207 EXPECT_EQ(1u, tooltip_aura_->GetLineSizeForTest());
202 } 208 }
203 209
210 #if defined(OS_CHROMEOS)
211 // crbug.com/664370.
212 TEST_F(TooltipControllerTest, MaxWidth) {
213 base::string16 text = base::ASCIIToUTF16(
214 "List of law clerks of the Supreme Court of the United States - "
215 "Wikipedia\n");
216 text += gfx::kEllipsisUTF16 + base::ASCIIToUTF16("wikipedia.org/") +
217 gfx::kEllipsisUTF16 +
218 base::ASCIIToUTF16(
219 "/List_of_law_clerks_of_the_Supreme_Court_of_the_Unite") +
220 +gfx::kEllipsisUTF16;
221
222 view_->set_tooltip_text(text);
223 generator_->MoveMouseToCenterOf(GetWindow());
224
225 // Fire tooltip timer so tooltip becomes visible.
226 helper_->FireTooltipTimer();
227
228 EXPECT_TRUE(helper_->IsTooltipVisible());
229 EXPECT_EQ(2u, tooltip_aura_->GetLineSizeForTest());
230 }
231 #endif
232
204 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { 233 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) {
205 // TODO: these tests use GetContext(). That should go away for aura-mus 234 // TODO: these tests use GetContext(). That should go away for aura-mus
206 // client. http://crbug.com/663781. 235 // client. http://crbug.com/663781.
207 if (IsAuraMusClient()) 236 if (IsAuraMusClient())
208 return; 237 return;
209 238
210 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); 239 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text"));
211 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); 240 EXPECT_EQ(base::string16(), helper_->GetTooltipText());
212 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); 241 EXPECT_EQ(NULL, helper_->GetTooltipWindow());
213 242
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 helper_->FireTooltipTimer(); 901 helper_->FireTooltipTimer();
873 tooltip_bounds1 = test_tooltip_->location(); 902 tooltip_bounds1 = test_tooltip_->location();
874 903
875 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); 904 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1);
876 EXPECT_EQ(reference_string, helper_->GetTooltipText()); 905 EXPECT_EQ(reference_string, helper_->GetTooltipText());
877 } 906 }
878 907
879 } // namespace test 908 } // namespace test
880 } // namespace corewm 909 } // namespace corewm
881 } // namespace views 910 } // namespace views
OLDNEW
« ui/gfx/test/render_text_test_api.h ('K') | « ui/views/corewm/tooltip_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698