| 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/test/ash_test_base.h" | 6 #include "ash/test/ash_test_base.h" |
| 7 #include "ash/tooltips/tooltip_controller.h" | 7 #include "ash/tooltips/tooltip_controller.h" |
| 8 #include "ash/wm/cursor_manager.h" |
| 8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 9 #include "ui/aura/client/tooltip_client.h" | 10 #include "ui/aura/client/tooltip_client.h" |
| 10 #include "ui/aura/cursor_manager.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/event_generator.h" | 13 #include "ui/aura/test/event_generator.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/text/text_elider.h" | 16 #include "ui/base/text/text_elider.h" |
| 17 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 18 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
| 19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 239 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 240 generator.MoveMouseRelativeTo(widget->GetNativeView(), | 240 generator.MoveMouseRelativeTo(widget->GetNativeView(), |
| 241 view->bounds().CenterPoint()); | 241 view->bounds().CenterPoint()); |
| 242 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); | 242 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 243 | 243 |
| 244 // Fire tooltip timer so tooltip becomes visible. | 244 // Fire tooltip timer so tooltip becomes visible. |
| 245 FireTooltipTimer(); | 245 FireTooltipTimer(); |
| 246 EXPECT_TRUE(IsTooltipVisible()); | 246 EXPECT_TRUE(IsTooltipVisible()); |
| 247 | 247 |
| 248 // Hide the cursor and check again. | 248 // Hide the cursor and check again. |
| 249 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); | 249 ash::Shell::GetInstance()->cursor_manager()->ShowCursor(false); |
| 250 FireTooltipTimer(); | 250 FireTooltipTimer(); |
| 251 EXPECT_FALSE(IsTooltipVisible()); | 251 EXPECT_FALSE(IsTooltipVisible()); |
| 252 | 252 |
| 253 // Show the cursor and re-check. | 253 // Show the cursor and re-check. |
| 254 aura::Env::GetInstance()->cursor_manager()->ShowCursor(true); | 254 ash::Shell::GetInstance()->cursor_manager()->ShowCursor(true); |
| 255 FireTooltipTimer(); | 255 FireTooltipTimer(); |
| 256 EXPECT_TRUE(IsTooltipVisible()); | 256 EXPECT_TRUE(IsTooltipVisible()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST_F(TooltipControllerTest, TrimTooltipToFitTests) { | 259 TEST_F(TooltipControllerTest, TrimTooltipToFitTests) { |
| 260 string16 tooltip; | 260 string16 tooltip; |
| 261 int max_width, line_count, expect_lines; | 261 int max_width, line_count, expect_lines; |
| 262 int max_pixel_width = 400; // copied from constants in tooltip_controller.cc | 262 int max_pixel_width = 400; // copied from constants in tooltip_controller.cc |
| 263 int max_lines = 10; // copied from constants in tooltip_controller.cc | 263 int max_lines = 10; // copied from constants in tooltip_controller.cc |
| 264 gfx::Font font = GetDefaultFont(); | 264 gfx::Font font = GetDefaultFont(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 max_width = line_count = -1; | 343 max_width = line_count = -1; |
| 344 tooltip = ASCIIToUTF16("Small Tool t\tip"); | 344 tooltip = ASCIIToUTF16("Small Tool t\tip"); |
| 345 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); | 345 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); |
| 346 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tool t\tip")), max_width); | 346 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tool t\tip")), max_width); |
| 347 EXPECT_EQ(1, line_count); | 347 EXPECT_EQ(1, line_count); |
| 348 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); | 348 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); |
| 349 } | 349 } |
| 350 | 350 |
| 351 } // namespace test | 351 } // namespace test |
| 352 } // namespace ash | 352 } // namespace ash |
| OLD | NEW |