| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 TEST_F(TooltipControllerTest, ViewTooltip) { | 181 TEST_F(TooltipControllerTest, ViewTooltip) { |
| 182 // TODO: these tests use GetContext(). That should go away for aura-mus | 182 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 183 // client. http://crbug.com/663781. | 183 // client. http://crbug.com/663781. |
| 184 if (IsMus()) | 184 if (IsMus()) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 187 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 188 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 188 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 189 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 189 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 190 | |
| 191 generator_->MoveMouseToCenterOf(GetWindow()); | 190 generator_->MoveMouseToCenterOf(GetWindow()); |
| 192 | 191 |
| 193 EXPECT_EQ(GetWindow(), GetRootWindow()->GetEventHandlerForPoint( | 192 EXPECT_EQ(GetWindow(), GetRootWindow()->GetEventHandlerForPoint( |
| 194 generator_->current_location())); | 193 generator_->current_location())); |
| 195 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); | 194 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 196 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); | 195 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 197 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 196 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 198 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); | 197 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 199 | 198 |
| 199 // Fire tooltip timer so tooltip becomes visible. |
| 200 helper_->FireTooltipTimer(); |
| 201 |
| 200 EXPECT_TRUE(helper_->IsTooltipVisible()); | 202 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 201 generator_->MoveMouseBy(1, 0); | 203 generator_->MoveMouseBy(1, 0); |
| 202 | 204 |
| 203 EXPECT_TRUE(helper_->IsTooltipVisible()); | 205 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 204 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); | 206 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 205 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 207 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 206 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); | 208 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 207 } | 209 } |
| 208 | 210 |
| 209 #if defined(OS_CHROMEOS) | 211 #if defined(OS_CHROMEOS) |
| 210 // crbug.com/664370. | 212 // crbug.com/664370. |
| 211 TEST_F(TooltipControllerTest, MaxWidth) { | 213 TEST_F(TooltipControllerTest, MaxWidth) { |
| 212 // TODO: these tests use GetContext(). That should go away for mus client. | 214 // TODO: these tests use GetContext(). That should go away for mus client. |
| 213 // http://crbug.com/663781. | 215 // http://crbug.com/663781. |
| 214 if (IsMus()) | 216 if (IsMus()) |
| 215 return; | 217 return; |
| 216 | 218 |
| 217 base::string16 text = base::ASCIIToUTF16( | 219 base::string16 text = base::ASCIIToUTF16( |
| 218 "Really really realy long long long long long tooltips that exceeds max " | 220 "Really really realy long long long long long tooltips that exceeds max " |
| 219 "width"); | 221 "width"); |
| 220 view_->set_tooltip_text(text); | 222 view_->set_tooltip_text(text); |
| 221 gfx::Point center = GetWindow()->bounds().CenterPoint(); | 223 gfx::Point center = GetWindow()->bounds().CenterPoint(); |
| 224 generator_->MoveMouseTo(center); |
| 222 | 225 |
| 223 generator_->MoveMouseTo(center); | 226 // Fire tooltip timer so tooltip becomes visible. |
| 227 helper_->FireTooltipTimer(); |
| 224 | 228 |
| 225 EXPECT_TRUE(helper_->IsTooltipVisible()); | 229 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 226 gfx::RenderText* render_text = | 230 gfx::RenderText* render_text = |
| 227 test::TooltipAuraTestApi(tooltip_aura_).GetRenderText(); | 231 test::TooltipAuraTestApi(tooltip_aura_).GetRenderText(); |
| 228 | 232 |
| 229 int max = helper_->controller()->GetMaxWidth(center); | 233 int max = helper_->controller()->GetMaxWidth(center); |
| 230 EXPECT_EQ(max, render_text->display_rect().width()); | 234 EXPECT_EQ(max, render_text->display_rect().width()); |
| 231 } | 235 } |
| 232 #endif | 236 #endif |
| 233 | 237 |
| 234 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { | 238 TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { |
| 235 // TODO: these tests use GetContext(). That should go away for aura-mus | 239 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 236 // client. http://crbug.com/663781. | 240 // client. http://crbug.com/663781. |
| 237 if (IsMus()) | 241 if (IsMus()) |
| 238 return; | 242 return; |
| 239 | 243 |
| 240 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 244 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 241 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 245 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 242 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 246 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 243 | 247 |
| 244 PrepareSecondView(); | 248 PrepareSecondView(); |
| 245 aura::Window* window = GetWindow(); | 249 aura::Window* window = GetWindow(); |
| 246 aura::Window* root_window = GetRootWindow(); | 250 aura::Window* root_window = GetRootWindow(); |
| 247 | 251 |
| 252 // Fire tooltip timer so tooltip becomes visible. |
| 248 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); | 253 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); |
| 254 helper_->FireTooltipTimer(); |
| 249 EXPECT_TRUE(helper_->IsTooltipVisible()); | 255 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 250 for (int i = 0; i < 49; ++i) { | 256 for (int i = 0; i < 49; ++i) { |
| 251 generator_->MoveMouseBy(1, 0); | 257 generator_->MoveMouseBy(1, 0); |
| 252 EXPECT_TRUE(helper_->IsTooltipVisible()); | 258 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 253 EXPECT_EQ(window, root_window->GetEventHandlerForPoint( | 259 EXPECT_EQ(window, root_window->GetEventHandlerForPoint( |
| 254 generator_->current_location())); | 260 generator_->current_location())); |
| 255 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); | 261 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 256 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); | 262 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); |
| 257 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 263 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 258 EXPECT_EQ(window, helper_->GetTooltipWindow()); | 264 EXPECT_EQ(window, helper_->GetTooltipWindow()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 273 // TODO: these tests use GetContext(). That should go away for aura-mus | 279 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 274 // client. http://crbug.com/663781. | 280 // client. http://crbug.com/663781. |
| 275 if (IsMus()) | 281 if (IsMus()) |
| 276 return; | 282 return; |
| 277 | 283 |
| 278 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 284 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 279 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 285 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 280 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 286 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 281 | 287 |
| 282 generator_->MoveMouseRelativeTo(GetWindow(), view_->bounds().CenterPoint()); | 288 generator_->MoveMouseRelativeTo(GetWindow(), view_->bounds().CenterPoint()); |
| 289 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 290 |
| 291 // Fire tooltip timer so tooltip becomes visible. |
| 292 helper_->FireTooltipTimer(); |
| 283 EXPECT_TRUE(helper_->IsTooltipVisible()); | 293 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 284 | 294 |
| 285 // Disable tooltips and check again. | 295 // Disable tooltips and check again. |
| 286 helper_->controller()->SetTooltipsEnabled(false); | 296 helper_->controller()->SetTooltipsEnabled(false); |
| 287 EXPECT_FALSE(helper_->IsTooltipVisible()); | 297 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 288 helper_->UpdateIfRequired(); | 298 helper_->FireTooltipTimer(); |
| 289 EXPECT_FALSE(helper_->IsTooltipVisible()); | 299 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 290 | 300 |
| 291 // Enable tooltips back and check again. | 301 // Enable tooltips back and check again. |
| 292 helper_->controller()->SetTooltipsEnabled(true); | 302 helper_->controller()->SetTooltipsEnabled(true); |
| 293 EXPECT_FALSE(helper_->IsTooltipVisible()); | 303 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 294 helper_->UpdateIfRequired(); | 304 helper_->FireTooltipTimer(); |
| 295 EXPECT_TRUE(helper_->IsTooltipVisible()); | 305 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 296 } | 306 } |
| 297 | 307 |
| 298 // Verifies tooltip isn't shown if tooltip text consists entirely of whitespace. | 308 // Verifies tooltip isn't shown if tooltip text consists entirely of whitespace. |
| 299 TEST_F(TooltipControllerTest, DontShowEmptyTooltips) { | 309 TEST_F(TooltipControllerTest, DontShowEmptyTooltips) { |
| 300 // TODO: these tests use GetContext(). That should go away for aura-mus | 310 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 301 // client. http://crbug.com/663781. | 311 // client. http://crbug.com/663781. |
| 302 if (IsMus()) | 312 if (IsMus()) |
| 303 return; | 313 return; |
| 304 | 314 |
| 305 view_->set_tooltip_text(ASCIIToUTF16(" ")); | 315 view_->set_tooltip_text(ASCIIToUTF16(" ")); |
| 306 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 316 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 307 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 317 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 308 | 318 |
| 309 generator_->MoveMouseRelativeTo(GetWindow(), view_->bounds().CenterPoint()); | 319 generator_->MoveMouseRelativeTo(GetWindow(), view_->bounds().CenterPoint()); |
| 320 |
| 321 helper_->FireTooltipTimer(); |
| 310 EXPECT_FALSE(helper_->IsTooltipVisible()); | 322 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 311 } | 323 } |
| 312 | 324 |
| 313 TEST_F(TooltipControllerTest, TooltipHidesOnKeyPressAndStaysHiddenUntilChange) { | 325 TEST_F(TooltipControllerTest, TooltipHidesOnKeyPressAndStaysHiddenUntilChange) { |
| 314 // TODO: these tests use GetContext(). That should go away for aura-mus | 326 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 315 // client. http://crbug.com/663781. | 327 // client. http://crbug.com/663781. |
| 316 if (IsMus()) | 328 if (IsMus()) |
| 317 return; | 329 return; |
| 318 | 330 |
| 319 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1")); | 331 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1")); |
| 320 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 332 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 321 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 333 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 322 | 334 |
| 323 TooltipTestView* view2 = PrepareSecondView(); | 335 TooltipTestView* view2 = PrepareSecondView(); |
| 324 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 2")); | 336 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 2")); |
| 325 | 337 |
| 326 aura::Window* window = GetWindow(); | 338 aura::Window* window = GetWindow(); |
| 327 | 339 |
| 340 // Fire tooltip timer so tooltip becomes visible. |
| 328 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); | 341 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); |
| 342 helper_->FireTooltipTimer(); |
| 329 EXPECT_TRUE(helper_->IsTooltipVisible()); | 343 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 330 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); | 344 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); |
| 331 | 345 |
| 332 generator_->PressKey(ui::VKEY_1, 0); | 346 generator_->PressKey(ui::VKEY_1, 0); |
| 333 EXPECT_FALSE(helper_->IsTooltipVisible()); | 347 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 348 EXPECT_FALSE(helper_->IsTooltipTimerRunning()); |
| 334 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); | 349 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); |
| 335 | 350 |
| 336 // Moving the mouse inside |view1| should not change the state of the tooltip | 351 // Moving the mouse inside |view1| should not change the state of the tooltip |
| 337 // or the timers. | 352 // or the timers. |
| 338 for (int i = 0; i < 49; i++) { | 353 for (int i = 0; i < 49; i++) { |
| 339 generator_->MoveMouseBy(1, 0); | 354 generator_->MoveMouseBy(1, 0); |
| 340 EXPECT_FALSE(helper_->IsTooltipVisible()); | 355 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 356 EXPECT_FALSE(helper_->IsTooltipTimerRunning()); |
| 341 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); | 357 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); |
| 342 EXPECT_EQ(window, | 358 EXPECT_EQ(window, |
| 343 GetRootWindow()->GetEventHandlerForPoint( | 359 GetRootWindow()->GetEventHandlerForPoint( |
| 344 generator_->current_location())); | 360 generator_->current_location())); |
| 345 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); | 361 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); |
| 346 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); | 362 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); |
| 347 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 363 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 348 EXPECT_EQ(window, helper_->GetTooltipWindow()); | 364 EXPECT_EQ(window, helper_->GetTooltipWindow()); |
| 349 } | 365 } |
| 350 | 366 |
| 351 // Now we move the mouse on to |view2|. It should update the tooltip. | 367 // Now we move the mouse on to |view2|. It should re-start the tooltip timer. |
| 352 generator_->MoveMouseBy(1, 0); | 368 generator_->MoveMouseBy(1, 0); |
| 353 | 369 EXPECT_TRUE(helper_->IsTooltipTimerRunning()); |
| 370 helper_->FireTooltipTimer(); |
| 354 EXPECT_TRUE(helper_->IsTooltipVisible()); | 371 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 355 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); | 372 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); |
| 356 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 2"); | 373 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 2"); |
| 357 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); | 374 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); |
| 358 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 375 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 359 EXPECT_EQ(window, helper_->GetTooltipWindow()); | 376 EXPECT_EQ(window, helper_->GetTooltipWindow()); |
| 360 } | 377 } |
| 361 | 378 |
| 362 TEST_F(TooltipControllerTest, TooltipHidesOnTimeoutAndStaysHiddenUntilChange) { | 379 TEST_F(TooltipControllerTest, TooltipHidesOnTimeoutAndStaysHiddenUntilChange) { |
| 363 // TODO: these tests use GetContext(). That should go away for aura-mus | 380 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 364 // client. http://crbug.com/663781. | 381 // client. http://crbug.com/663781. |
| 365 if (IsMus()) | 382 if (IsMus()) |
| 366 return; | 383 return; |
| 367 | 384 |
| 368 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1")); | 385 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1")); |
| 369 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 386 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 370 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); | 387 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 371 | 388 |
| 372 TooltipTestView* view2 = PrepareSecondView(); | 389 TooltipTestView* view2 = PrepareSecondView(); |
| 373 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 2")); | 390 view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 2")); |
| 374 | 391 |
| 375 aura::Window* window = GetWindow(); | 392 aura::Window* window = GetWindow(); |
| 376 | 393 |
| 377 // Update tooltip so tooltip becomes visible. | 394 // Fire tooltip timer so tooltip becomes visible. |
| 378 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); | 395 generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); |
| 396 helper_->FireTooltipTimer(); |
| 379 EXPECT_TRUE(helper_->IsTooltipVisible()); | 397 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 380 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); | 398 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); |
| 381 | 399 |
| 382 helper_->FireTooltipShownTimer(); | 400 helper_->FireTooltipShownTimer(); |
| 383 EXPECT_FALSE(helper_->IsTooltipVisible()); | 401 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 402 EXPECT_FALSE(helper_->IsTooltipTimerRunning()); |
| 384 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); | 403 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); |
| 385 | 404 |
| 386 // Moving the mouse inside |view1| should not change the state of the tooltip | 405 // Moving the mouse inside |view1| should not change the state of the tooltip |
| 387 // or the timers. | 406 // or the timers. |
| 388 for (int i = 0; i < 49; ++i) { | 407 for (int i = 0; i < 49; ++i) { |
| 389 generator_->MoveMouseBy(1, 0); | 408 generator_->MoveMouseBy(1, 0); |
| 390 EXPECT_FALSE(helper_->IsTooltipVisible()); | 409 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 410 EXPECT_FALSE(helper_->IsTooltipTimerRunning()); |
| 391 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); | 411 EXPECT_FALSE(helper_->IsTooltipShownTimerRunning()); |
| 392 EXPECT_EQ(window, GetRootWindow()->GetEventHandlerForPoint( | 412 EXPECT_EQ(window, GetRootWindow()->GetEventHandlerForPoint( |
| 393 generator_->current_location())); | 413 generator_->current_location())); |
| 394 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); | 414 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); |
| 395 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); | 415 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); |
| 396 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 416 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 397 EXPECT_EQ(window, helper_->GetTooltipWindow()); | 417 EXPECT_EQ(window, helper_->GetTooltipWindow()); |
| 398 } | 418 } |
| 399 | 419 |
| 400 // Now we move the mouse on to |view2|. It should update the tooltip. | 420 // Now we move the mouse on to |view2|. It should re-start the tooltip timer. |
| 401 generator_->MoveMouseBy(1, 0); | 421 generator_->MoveMouseBy(1, 0); |
| 402 | 422 EXPECT_TRUE(helper_->IsTooltipTimerRunning()); |
| 423 helper_->FireTooltipTimer(); |
| 403 EXPECT_TRUE(helper_->IsTooltipVisible()); | 424 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 404 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); | 425 EXPECT_TRUE(helper_->IsTooltipShownTimerRunning()); |
| 405 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 2"); | 426 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 2"); |
| 406 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); | 427 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); |
| 407 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 428 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 408 EXPECT_EQ(window, helper_->GetTooltipWindow()); | 429 EXPECT_EQ(window, helper_->GetTooltipWindow()); |
| 409 } | 430 } |
| 410 | 431 |
| 411 // Verifies a mouse exit event hides the tooltips. | 432 // Verifies a mouse exit event hides the tooltips. |
| 412 TEST_F(TooltipControllerTest, HideOnExit) { | 433 TEST_F(TooltipControllerTest, HideOnExit) { |
| 413 // TODO: these tests use GetContext(). That should go away for aura-mus | 434 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 414 // client. http://crbug.com/663781. | 435 // client. http://crbug.com/663781. |
| 415 if (IsMus()) | 436 if (IsMus()) |
| 416 return; | 437 return; |
| 417 | 438 |
| 418 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 439 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 419 generator_->MoveMouseToCenterOf(GetWindow()); | 440 generator_->MoveMouseToCenterOf(GetWindow()); |
| 420 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); | 441 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 421 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); | 442 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 422 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); | 443 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 423 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); | 444 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 424 | 445 |
| 446 // Fire tooltip timer so tooltip becomes visible. |
| 447 helper_->FireTooltipTimer(); |
| 448 |
| 425 EXPECT_TRUE(helper_->IsTooltipVisible()); | 449 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 426 generator_->SendMouseExit(); | 450 generator_->SendMouseExit(); |
| 427 EXPECT_FALSE(helper_->IsTooltipVisible()); | 451 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 428 } | 452 } |
| 429 | 453 |
| 430 TEST_F(TooltipControllerTest, ReshowOnClickAfterEnterExit) { | 454 TEST_F(TooltipControllerTest, ReshowOnClickAfterEnterExit) { |
| 431 // TODO: these tests use GetContext(). That should go away for aura-mus | 455 // TODO: these tests use GetContext(). That should go away for aura-mus |
| 432 // client. http://crbug.com/663781. | 456 // client. http://crbug.com/663781. |
| 433 if (IsMus()) | 457 if (IsMus()) |
| 434 return; | 458 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 445 v2->SetBoundsRect(view_bounds); | 469 v2->SetBoundsRect(view_bounds); |
| 446 const base::string16 v1_tt(ASCIIToUTF16("v1")); | 470 const base::string16 v1_tt(ASCIIToUTF16("v1")); |
| 447 const base::string16 v2_tt(ASCIIToUTF16("v2")); | 471 const base::string16 v2_tt(ASCIIToUTF16("v2")); |
| 448 v1->set_tooltip_text(v1_tt); | 472 v1->set_tooltip_text(v1_tt); |
| 449 v2->set_tooltip_text(v2_tt); | 473 v2->set_tooltip_text(v2_tt); |
| 450 | 474 |
| 451 gfx::Point v1_point(1, 1); | 475 gfx::Point v1_point(1, 1); |
| 452 View::ConvertPointToWidget(v1, &v1_point); | 476 View::ConvertPointToWidget(v1, &v1_point); |
| 453 generator_->MoveMouseRelativeTo(GetWindow(), v1_point); | 477 generator_->MoveMouseRelativeTo(GetWindow(), v1_point); |
| 454 | 478 |
| 479 // Fire tooltip timer so tooltip becomes visible. |
| 480 helper_->FireTooltipTimer(); |
| 455 EXPECT_TRUE(helper_->IsTooltipVisible()); | 481 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 456 EXPECT_EQ(v1_tt, helper_->GetTooltipText()); | 482 EXPECT_EQ(v1_tt, helper_->GetTooltipText()); |
| 457 | 483 |
| 458 // Press the mouse, move to v2 and back to v1. | 484 // Press the mouse, move to v2 and back to v1. |
| 459 generator_->ClickLeftButton(); | 485 generator_->ClickLeftButton(); |
| 460 | 486 |
| 461 gfx::Point v2_point(1, 1); | 487 gfx::Point v2_point(1, 1); |
| 462 View::ConvertPointToWidget(v2, &v2_point); | 488 View::ConvertPointToWidget(v2, &v2_point); |
| 463 generator_->MoveMouseRelativeTo(GetWindow(), v2_point); | 489 generator_->MoveMouseRelativeTo(GetWindow(), v2_point); |
| 464 generator_->MoveMouseRelativeTo(GetWindow(), v1_point); | 490 generator_->MoveMouseRelativeTo(GetWindow(), v1_point); |
| 465 | 491 |
| 492 helper_->FireTooltipTimer(); |
| 466 EXPECT_TRUE(helper_->IsTooltipVisible()); | 493 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 467 EXPECT_EQ(v1_tt, helper_->GetTooltipText()); | 494 EXPECT_EQ(v1_tt, helper_->GetTooltipText()); |
| 468 } | 495 } |
| 469 | 496 |
| 470 namespace { | 497 namespace { |
| 471 | 498 |
| 472 // Returns the index of |window| in its parent's children. | 499 // Returns the index of |window| in its parent's children. |
| 473 int IndexInParent(const aura::Window* window) { | 500 int IndexInParent(const aura::Window* window) { |
| 474 aura::Window::Windows::const_iterator i = | 501 aura::Window::Windows::const_iterator i = |
| 475 std::find(window->parent()->children().begin(), | 502 std::find(window->parent()->children().begin(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 547 |
| 521 view_->GetWidget()->SetCapture(view_); | 548 view_->GetWidget()->SetCapture(view_); |
| 522 RunPendingMessages(); | 549 RunPendingMessages(); |
| 523 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 550 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 524 generator_->MoveMouseToCenterOf(GetWindow()); | 551 generator_->MoveMouseToCenterOf(GetWindow()); |
| 525 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); | 552 base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 526 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); | 553 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 527 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); | 554 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); |
| 528 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); | 555 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 529 | 556 |
| 557 // Fire tooltip timer so tooltip becomes visible. |
| 558 helper_->FireTooltipTimer(); |
| 559 |
| 530 EXPECT_TRUE(helper_->IsTooltipVisible()); | 560 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 531 view_->GetWidget()->ReleaseCapture(); | 561 view_->GetWidget()->ReleaseCapture(); |
| 532 EXPECT_FALSE(helper_->IsTooltipVisible()); | 562 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 533 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); | 563 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); |
| 534 } | 564 } |
| 535 | 565 |
| 536 // Disabled on linux as DesktopScreenX11::GetWindowAtScreenPoint() doesn't | 566 // Disabled on linux as DesktopScreenX11::GetWindowAtScreenPoint() doesn't |
| 537 // consider z-order. | 567 // consider z-order. |
| 538 // Disabled on Windows due to failing bots. http://crbug.com/604479 | 568 // Disabled on Windows due to failing bots. http://crbug.com/604479 |
| 539 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_WIN) | 569 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_WIN) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 565 | 595 |
| 566 widget_->SetCapture(view_); | 596 widget_->SetCapture(view_); |
| 567 EXPECT_TRUE(widget_->HasCapture()); | 597 EXPECT_TRUE(widget_->HasCapture()); |
| 568 widget2->Show(); | 598 widget2->Show(); |
| 569 EXPECT_GE(IndexInParent(widget2->GetNativeWindow()), | 599 EXPECT_GE(IndexInParent(widget2->GetNativeWindow()), |
| 570 IndexInParent(widget_->GetNativeWindow())); | 600 IndexInParent(widget_->GetNativeWindow())); |
| 571 | 601 |
| 572 generator_->MoveMouseRelativeTo(widget_->GetNativeWindow(), | 602 generator_->MoveMouseRelativeTo(widget_->GetNativeWindow(), |
| 573 view_->bounds().CenterPoint()); | 603 view_->bounds().CenterPoint()); |
| 574 | 604 |
| 605 EXPECT_TRUE(helper_->IsTooltipTimerRunning()); |
| 606 helper_->FireTooltipTimer(); |
| 575 // Even though the mouse is over a window with a tooltip it shouldn't be | 607 // Even though the mouse is over a window with a tooltip it shouldn't be |
| 576 // picked up because the windows don't have the same value for | 608 // picked up because the windows don't have the same value for |
| 577 // |TooltipManager::kGroupingPropertyKey|. | 609 // |TooltipManager::kGroupingPropertyKey|. |
| 578 EXPECT_TRUE(helper_->GetTooltipText().empty()); | 610 EXPECT_TRUE(helper_->GetTooltipText().empty()); |
| 579 | 611 |
| 580 // Now make both the windows have same transient value for | 612 // Now make both the windows have same transient value for |
| 581 // kGroupingPropertyKey. In this case the tooltip should be picked up from | 613 // kGroupingPropertyKey. In this case the tooltip should be picked up from |
| 582 // |widget2| (because the mouse is over it). | 614 // |widget2| (because the mouse is over it). |
| 583 const int grouping_key = 1; | 615 const int grouping_key = 1; |
| 584 widget_->SetNativeWindowProperty(TooltipManager::kGroupingPropertyKey, | 616 widget_->SetNativeWindowProperty(TooltipManager::kGroupingPropertyKey, |
| 585 reinterpret_cast<void*>(grouping_key)); | 617 reinterpret_cast<void*>(grouping_key)); |
| 586 widget2->SetNativeWindowProperty(TooltipManager::kGroupingPropertyKey, | 618 widget2->SetNativeWindowProperty(TooltipManager::kGroupingPropertyKey, |
| 587 reinterpret_cast<void*>(grouping_key)); | 619 reinterpret_cast<void*>(grouping_key)); |
| 588 generator_->MoveMouseBy(1, 10); | 620 generator_->MoveMouseBy(1, 10); |
| 621 EXPECT_TRUE(helper_->IsTooltipTimerRunning()); |
| 622 helper_->FireTooltipTimer(); |
| 589 EXPECT_EQ(tooltip_text2, helper_->GetTooltipText()); | 623 EXPECT_EQ(tooltip_text2, helper_->GetTooltipText()); |
| 590 | 624 |
| 591 widget2.reset(); | 625 widget2.reset(); |
| 592 } | 626 } |
| 593 | 627 |
| 594 namespace { | 628 namespace { |
| 595 | 629 |
| 596 class TestTooltip : public Tooltip { | 630 class TestTooltip : public Tooltip { |
| 597 public: | 631 public: |
| 598 TestTooltip() : is_visible_(false) {} | 632 TestTooltip() : is_visible_(false) {} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2); | 697 DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2); |
| 664 }; | 698 }; |
| 665 | 699 |
| 666 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) { | 700 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) { |
| 667 aura::test::TestWindowDelegate test_delegate; | 701 aura::test::TestWindowDelegate test_delegate; |
| 668 std::unique_ptr<aura::Window> window( | 702 std::unique_ptr<aura::Window> window( |
| 669 CreateNormalWindow(100, root_window(), &test_delegate)); | 703 CreateNormalWindow(100, root_window(), &test_delegate)); |
| 670 window->SetBounds(gfx::Rect(0, 0, 300, 300)); | 704 window->SetBounds(gfx::Rect(0, 0, 300, 300)); |
| 671 base::string16 tooltip_text(ASCIIToUTF16(" \nx ")); | 705 base::string16 tooltip_text(ASCIIToUTF16(" \nx ")); |
| 672 aura::client::SetTooltipText(window.get(), &tooltip_text); | 706 aura::client::SetTooltipText(window.get(), &tooltip_text); |
| 673 EXPECT_FALSE(helper_->IsTooltipVisible()); | |
| 674 generator_->MoveMouseToCenterOf(window.get()); | 707 generator_->MoveMouseToCenterOf(window.get()); |
| 708 helper_->FireTooltipTimer(); |
| 675 EXPECT_EQ(ASCIIToUTF16("x"), test_tooltip_->tooltip_text()); | 709 EXPECT_EQ(ASCIIToUTF16("x"), test_tooltip_->tooltip_text()); |
| 676 } | 710 } |
| 677 | 711 |
| 678 // Verifies that tooltip is hidden and tooltip window closed upon cancel mode. | 712 // Verifies that tooltip is hidden and tooltip window closed upon cancel mode. |
| 679 TEST_F(TooltipControllerTest2, CloseOnCancelMode) { | 713 TEST_F(TooltipControllerTest2, CloseOnCancelMode) { |
| 680 aura::test::TestWindowDelegate test_delegate; | 714 aura::test::TestWindowDelegate test_delegate; |
| 681 std::unique_ptr<aura::Window> window( | 715 std::unique_ptr<aura::Window> window( |
| 682 CreateNormalWindow(100, root_window(), &test_delegate)); | 716 CreateNormalWindow(100, root_window(), &test_delegate)); |
| 683 window->SetBounds(gfx::Rect(0, 0, 300, 300)); | 717 window->SetBounds(gfx::Rect(0, 0, 300, 300)); |
| 684 base::string16 tooltip_text(ASCIIToUTF16("Tooltip Text")); | 718 base::string16 tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 685 aura::client::SetTooltipText(window.get(), &tooltip_text); | 719 aura::client::SetTooltipText(window.get(), &tooltip_text); |
| 686 EXPECT_FALSE(helper_->IsTooltipVisible()); | |
| 687 generator_->MoveMouseToCenterOf(window.get()); | 720 generator_->MoveMouseToCenterOf(window.get()); |
| 688 | 721 |
| 722 // Fire tooltip timer so tooltip becomes visible. |
| 723 helper_->FireTooltipTimer(); |
| 689 EXPECT_TRUE(helper_->IsTooltipVisible()); | 724 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 690 | 725 |
| 691 // Send OnCancelMode event and verify that tooltip becomes invisible and | 726 // Send OnCancelMode event and verify that tooltip becomes invisible and |
| 692 // the tooltip window is closed. | 727 // the tooltip window is closed. |
| 693 ui::CancelModeEvent event; | 728 ui::CancelModeEvent event; |
| 694 helper_->controller()->OnCancelMode(&event); | 729 helper_->controller()->OnCancelMode(&event); |
| 695 EXPECT_FALSE(helper_->IsTooltipVisible()); | 730 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 696 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); | 731 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); |
| 697 } | 732 } |
| 698 | 733 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 v1->SetBoundsRect(view_bounds); | 842 v1->SetBoundsRect(view_bounds); |
| 808 v1_1->SetBounds(0, 0, 3, 3); | 843 v1_1->SetBounds(0, 0, 3, 3); |
| 809 view_bounds.set_y(view_bounds.height()); | 844 view_bounds.set_y(view_bounds.height()); |
| 810 v2->SetBoundsRect(view_bounds); | 845 v2->SetBoundsRect(view_bounds); |
| 811 v2_2->SetBounds(view_bounds.width() - 3, view_bounds.height() - 3, 3, 3); | 846 v2_2->SetBounds(view_bounds.width() - 3, view_bounds.height() - 3, 3, 3); |
| 812 v2_1->SetBounds(0, 0, 3, 3); | 847 v2_1->SetBounds(0, 0, 3, 3); |
| 813 | 848 |
| 814 // Test whether a toolbar appears on v1 | 849 // Test whether a toolbar appears on v1 |
| 815 gfx::Point center = v1->bounds().CenterPoint(); | 850 gfx::Point center = v1->bounds().CenterPoint(); |
| 816 generator_->MoveMouseRelativeTo(GetWindow(), center); | 851 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 852 helper_->FireTooltipTimer(); |
| 817 EXPECT_TRUE(helper_->IsTooltipVisible()); | 853 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 818 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 854 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 819 gfx::Point tooltip_bounds1 = test_tooltip_->location(); | 855 gfx::Point tooltip_bounds1 = test_tooltip_->location(); |
| 820 | 856 |
| 821 // Test whether the toolbar changes position on mouse over v2 | 857 // Test whether the toolbar changes position on mouse over v2 |
| 822 center = v2->bounds().CenterPoint(); | 858 center = v2->bounds().CenterPoint(); |
| 823 generator_->MoveMouseRelativeTo(GetWindow(), center); | 859 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 860 helper_->FireTooltipTimer(); |
| 824 EXPECT_TRUE(helper_->IsTooltipVisible()); | 861 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 825 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 862 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 826 gfx::Point tooltip_bounds2 = test_tooltip_->location(); | 863 gfx::Point tooltip_bounds2 = test_tooltip_->location(); |
| 827 | 864 |
| 828 EXPECT_NE(tooltip_bounds1, gfx::Point()); | 865 EXPECT_NE(tooltip_bounds1, gfx::Point()); |
| 829 EXPECT_NE(tooltip_bounds2, gfx::Point()); | 866 EXPECT_NE(tooltip_bounds2, gfx::Point()); |
| 830 EXPECT_NE(tooltip_bounds1, tooltip_bounds2); | 867 EXPECT_NE(tooltip_bounds1, tooltip_bounds2); |
| 831 | 868 |
| 832 // Test if the toolbar does not change position on encountering a contained | 869 // Test if the toolbar does not change position on encountering a contained |
| 833 // view with the same tooltip text | 870 // view with the same tooltip text |
| 834 center = v2_1->GetLocalBounds().CenterPoint(); | 871 center = v2_1->GetLocalBounds().CenterPoint(); |
| 835 views::View::ConvertPointToTarget(v2_1, view_, ¢er); | 872 views::View::ConvertPointToTarget(v2_1, view_, ¢er); |
| 836 generator_->MoveMouseRelativeTo(GetWindow(), center); | 873 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 874 helper_->FireTooltipTimer(); |
| 837 gfx::Point tooltip_bounds2_1 = test_tooltip_->location(); | 875 gfx::Point tooltip_bounds2_1 = test_tooltip_->location(); |
| 838 | 876 |
| 839 EXPECT_NE(tooltip_bounds2, tooltip_bounds2_1); | 877 EXPECT_NE(tooltip_bounds2, tooltip_bounds2_1); |
| 840 EXPECT_TRUE(helper_->IsTooltipVisible()); | 878 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 841 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 879 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 842 | 880 |
| 843 // Test if the toolbar changes position on encountering a contained | 881 // Test if the toolbar changes position on encountering a contained |
| 844 // view with a different tooltip text | 882 // view with a different tooltip text |
| 845 center = v2_2->GetLocalBounds().CenterPoint(); | 883 center = v2_2->GetLocalBounds().CenterPoint(); |
| 846 views::View::ConvertPointToTarget(v2_2, view_, ¢er); | 884 views::View::ConvertPointToTarget(v2_2, view_, ¢er); |
| 847 generator_->MoveMouseRelativeTo(GetWindow(), center); | 885 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 886 helper_->FireTooltipTimer(); |
| 848 gfx::Point tooltip_bounds2_2 = test_tooltip_->location(); | 887 gfx::Point tooltip_bounds2_2 = test_tooltip_->location(); |
| 849 | 888 |
| 850 EXPECT_NE(tooltip_bounds2_1, tooltip_bounds2_2); | 889 EXPECT_NE(tooltip_bounds2_1, tooltip_bounds2_2); |
| 851 EXPECT_TRUE(helper_->IsTooltipVisible()); | 890 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 852 EXPECT_EQ(alternative_string, helper_->GetTooltipText()); | 891 EXPECT_EQ(alternative_string, helper_->GetTooltipText()); |
| 853 | 892 |
| 854 // Test if moving from a view that is contained by a larger view, both with | 893 // Test if moving from a view that is contained by a larger view, both with |
| 855 // the same tooltip text, does not change tooltip's position. | 894 // the same tooltip text, does not change tooltip's position. |
| 856 center = v1_1->GetLocalBounds().CenterPoint(); | 895 center = v1_1->GetLocalBounds().CenterPoint(); |
| 857 views::View::ConvertPointToTarget(v1_1, view_, ¢er); | 896 views::View::ConvertPointToTarget(v1_1, view_, ¢er); |
| 858 generator_->MoveMouseRelativeTo(GetWindow(), center); | 897 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 898 helper_->FireTooltipTimer(); |
| 859 gfx::Point tooltip_bounds1_1 = test_tooltip_->location(); | 899 gfx::Point tooltip_bounds1_1 = test_tooltip_->location(); |
| 860 | 900 |
| 861 EXPECT_TRUE(helper_->IsTooltipVisible()); | 901 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 862 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 902 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 863 | 903 |
| 864 center = v1->bounds().CenterPoint(); | 904 center = v1->bounds().CenterPoint(); |
| 865 generator_->MoveMouseRelativeTo(GetWindow(), center); | 905 generator_->MoveMouseRelativeTo(GetWindow(), center); |
| 906 helper_->FireTooltipTimer(); |
| 866 tooltip_bounds1 = test_tooltip_->location(); | 907 tooltip_bounds1 = test_tooltip_->location(); |
| 867 | 908 |
| 868 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); | 909 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); |
| 869 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 910 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 870 } | 911 } |
| 871 | 912 |
| 872 } // namespace test | 913 } // namespace test |
| 873 } // namespace corewm | 914 } // namespace corewm |
| 874 } // namespace views | 915 } // namespace views |
| OLD | NEW |