| OLD | NEW |
| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 generator_->MoveMouseToCenterOf(GetWindow()); | 219 generator_->MoveMouseToCenterOf(GetWindow()); |
| 220 generator_->MoveMouseBy(1, 0); | 220 generator_->MoveMouseBy(1, 0); |
| 221 EXPECT_TRUE(helper_->IsTooltipVisible()); | 221 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 222 | 222 |
| 223 view_->set_tooltip_text(ASCIIToUTF16(" ")); | 223 view_->set_tooltip_text(ASCIIToUTF16(" ")); |
| 224 generator_->MoveMouseBy(1, 0); | 224 generator_->MoveMouseBy(1, 0); |
| 225 EXPECT_FALSE(helper_->IsTooltipVisible()); | 225 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 TEST_F(TooltipControllerTest, DontShowTooltipOnTouch) { |
| 229 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 230 // client. http://crbug.com/663781. |
| 231 if (IsMus()) |
| 232 return; |
| 233 |
| 234 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 235 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 236 EXPECT_EQ(nullptr, helper_->GetTooltipWindow()); |
| 237 |
| 238 generator_->PressMoveAndReleaseTouchToCenterOf(GetWindow()); |
| 239 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 240 EXPECT_EQ(nullptr, helper_->GetTooltipWindow()); |
| 241 |
| 242 generator_->MoveMouseToCenterOf(GetWindow()); |
| 243 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 244 EXPECT_EQ(nullptr, helper_->GetTooltipWindow()); |
| 245 |
| 246 generator_->MoveMouseBy(1, 0); |
| 247 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 248 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 249 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 250 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 251 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 252 } |
| 253 |
| 228 #if defined(OS_CHROMEOS) | 254 #if defined(OS_CHROMEOS) |
| 229 // crbug.com/664370. | 255 // crbug.com/664370. |
| 230 TEST_F(TooltipControllerTest, MaxWidth) { | 256 TEST_F(TooltipControllerTest, MaxWidth) { |
| 231 // TODO: these tests use GetContext(). That should go away for mus client. | 257 // TODO: these tests use GetContext(). That should go away for mus client. |
| 232 // http://crbug.com/663781. | 258 // http://crbug.com/663781. |
| 233 if (IsMus()) | 259 if (IsMus()) |
| 234 return; | 260 return; |
| 235 | 261 |
| 236 base::string16 text = base::ASCIIToUTF16( | 262 base::string16 text = base::ASCIIToUTF16( |
| 237 "Really really realy long long long long long tooltips that exceeds max " | 263 "Really really realy long long long long long tooltips that exceeds max " |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 generator_->MoveMouseRelativeTo(GetWindow(), center); | 910 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 885 tooltip_bounds1 = test_tooltip_->location(); | 911 tooltip_bounds1 = test_tooltip_->location(); |
| 886 | 912 |
| 887 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); | 913 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); |
| 888 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 914 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 889 } | 915 } |
| 890 | 916 |
| 891 } // namespace test | 917 } // namespace test |
| 892 } // namespace corewm | 918 } // namespace corewm |
| 893 } // namespace views | 919 } // namespace views |
| OLD | NEW |