| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 #include "ui/message_center/message_center_style.h" | 24 #include "ui/message_center/message_center_style.h" |
| 25 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
| 26 #include "ui/message_center/notification_list.h" | 26 #include "ui/message_center/notification_list.h" |
| 27 #include "ui/message_center/notification_types.h" | 27 #include "ui/message_center/notification_types.h" |
| 28 #include "ui/message_center/views/constants.h" | 28 #include "ui/message_center/views/constants.h" |
| 29 #include "ui/message_center/views/message_center_controller.h" | 29 #include "ui/message_center/views/message_center_controller.h" |
| 30 #include "ui/message_center/views/message_view_factory.h" | 30 #include "ui/message_center/views/message_view_factory.h" |
| 31 #include "ui/message_center/views/notification_button.h" | 31 #include "ui/message_center/views/notification_button.h" |
| 32 #include "ui/message_center/views/notification_control_buttons_view.h" |
| 33 #include "ui/message_center/views/padded_button.h" |
| 32 #include "ui/message_center/views/proportional_image_view.h" | 34 #include "ui/message_center/views/proportional_image_view.h" |
| 33 #include "ui/views/controls/button/image_button.h" | 35 #include "ui/views/controls/button/image_button.h" |
| 34 #include "ui/views/layout/fill_layout.h" | 36 #include "ui/views/layout/fill_layout.h" |
| 35 #include "ui/views/test/views_test_base.h" | 37 #include "ui/views/test/views_test_base.h" |
| 36 #include "ui/views/test/widget_test.h" | 38 #include "ui/views/test/widget_test.h" |
| 37 #include "ui/views/widget/widget_delegate.h" | 39 #include "ui/views/widget/widget_delegate.h" |
| 38 | 40 |
| 39 namespace message_center { | 41 namespace message_center { |
| 40 | 42 |
| 41 // A test delegate used for tests that deal with the notification settings | 43 // A test delegate used for tests that deal with the notification settings |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 155 |
| 154 gfx::Point current_point = (*current)->origin(); | 156 gfx::Point current_point = (*current)->origin(); |
| 155 views::View::ConvertPointToTarget( | 157 views::View::ConvertPointToTarget( |
| 156 (*current), notification_view(), ¤t_point); | 158 (*current), notification_view(), ¤t_point); |
| 157 | 159 |
| 158 EXPECT_LT(last_point.y(), current_point.y()); | 160 EXPECT_LT(last_point.y(), current_point.y()); |
| 159 last = current++; | 161 last = current++; |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 | 164 |
| 163 views::ImageButton* GetCloseButton() { | 165 PaddedButton* GetCloseButton() { |
| 164 return notification_view()->close_button(); | 166 return notification_view() |
| 167 ->control_buttons_view_->close_button_for_testing(); |
| 168 } |
| 169 |
| 170 PaddedButton* GetSettingsButton() { |
| 171 return notification_view() |
| 172 ->control_buttons_view_->settings_button_for_testing(); |
| 165 } | 173 } |
| 166 | 174 |
| 167 void UpdateNotificationViews() { | 175 void UpdateNotificationViews() { |
| 168 notification_view()->UpdateWithNotification(*notification()); | 176 notification_view()->UpdateWithNotification(*notification()); |
| 169 } | 177 } |
| 170 | 178 |
| 171 float GetNotificationSlideAmount() const { | 179 float GetNotificationSlideAmount() const { |
| 172 return notification_view_->GetSlideOutLayer() | 180 return notification_view_->GetSlideOutLayer() |
| 173 ->transform() | 181 ->transform() |
| 174 .To2dTranslation() | 182 .To2dTranslation() |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 EXPECT_TRUE(NULL != notification_view()->title_view_); | 309 EXPECT_TRUE(NULL != notification_view()->title_view_); |
| 302 EXPECT_TRUE(NULL != notification_view()->message_view_); | 310 EXPECT_TRUE(NULL != notification_view()->message_view_); |
| 303 EXPECT_TRUE(NULL != notification_view()->icon_view_); | 311 EXPECT_TRUE(NULL != notification_view()->icon_view_); |
| 304 EXPECT_TRUE(NULL != notification_view()->image_view_); | 312 EXPECT_TRUE(NULL != notification_view()->image_view_); |
| 305 | 313 |
| 306 notification()->set_image(gfx::Image()); | 314 notification()->set_image(gfx::Image()); |
| 307 notification()->set_title(base::ASCIIToUTF16("")); | 315 notification()->set_title(base::ASCIIToUTF16("")); |
| 308 notification()->set_message(base::ASCIIToUTF16("")); | 316 notification()->set_message(base::ASCIIToUTF16("")); |
| 309 notification()->set_icon(gfx::Image()); | 317 notification()->set_icon(gfx::Image()); |
| 310 | 318 |
| 311 notification_view()->CreateOrUpdateViews(*notification()); | 319 notification_view()->UpdateWithNotification(*notification()); |
| 312 EXPECT_TRUE(NULL == notification_view()->title_view_); | 320 EXPECT_TRUE(NULL == notification_view()->title_view_); |
| 313 EXPECT_TRUE(NULL == notification_view()->message_view_); | 321 EXPECT_TRUE(NULL == notification_view()->message_view_); |
| 314 EXPECT_TRUE(NULL == notification_view()->image_view_); | 322 EXPECT_TRUE(NULL == notification_view()->image_view_); |
| 315 EXPECT_TRUE(NULL == notification_view()->settings_button_view_); | 323 // Notification must have a control buttons view. |
| 324 EXPECT_TRUE(NULL != notification_view()->control_buttons_view_); |
| 325 // Notification is not pinned and have a close button by default. |
| 326 EXPECT_TRUE(NULL != GetCloseButton()); |
| 327 // Notification doesn't have a settings button by default. |
| 328 EXPECT_TRUE(NULL == GetSettingsButton()); |
| 316 // We still expect an icon view for all layouts. | 329 // We still expect an icon view for all layouts. |
| 317 EXPECT_TRUE(NULL != notification_view()->icon_view_); | 330 EXPECT_TRUE(NULL != notification_view()->icon_view_); |
| 318 } | 331 } |
| 319 | 332 |
| 320 TEST_F(NotificationViewTest, CreateOrUpdateTestSettingsButton) { | 333 TEST_F(NotificationViewTest, CreateOrUpdateTestSettingsButton) { |
| 321 scoped_refptr<NotificationSettingsDelegate> delegate = | 334 scoped_refptr<NotificationSettingsDelegate> delegate = |
| 322 new NotificationSettingsDelegate(); | 335 new NotificationSettingsDelegate(); |
| 323 Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, | 336 Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, |
| 324 std::string("notification id"), base::UTF8ToUTF16("title"), | 337 std::string("notification id"), base::UTF8ToUTF16("title"), |
| 325 base::UTF8ToUTF16("message"), CreateTestImage(80, 80), | 338 base::UTF8ToUTF16("message"), CreateTestImage(80, 80), |
| 326 base::UTF8ToUTF16("display source"), | 339 base::UTF8ToUTF16("display source"), |
| 327 GURL("https://hello.com"), | 340 GURL("https://hello.com"), |
| 328 NotifierId(NotifierId::APPLICATION, "extension_id"), | 341 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 329 *data(), delegate.get()); | 342 *data(), delegate.get()); |
| 330 | 343 |
| 331 notification_view()->CreateOrUpdateViews(notf); | 344 notification_view()->UpdateWithNotification(notf); |
| 332 EXPECT_TRUE(NULL != notification_view()->title_view_); | 345 EXPECT_TRUE(NULL != notification_view()->title_view_); |
| 333 EXPECT_TRUE(NULL != notification_view()->message_view_); | 346 EXPECT_TRUE(NULL != notification_view()->message_view_); |
| 334 EXPECT_TRUE(NULL != notification_view()->context_message_view_); | 347 EXPECT_TRUE(NULL != notification_view()->context_message_view_); |
| 335 EXPECT_TRUE(NULL != notification_view()->settings_button_view_); | 348 EXPECT_TRUE(NULL != GetCloseButton()); |
| 349 EXPECT_TRUE(NULL != GetSettingsButton()); |
| 336 EXPECT_TRUE(NULL != notification_view()->icon_view_); | 350 EXPECT_TRUE(NULL != notification_view()->icon_view_); |
| 337 | 351 |
| 338 EXPECT_TRUE(NULL == notification_view()->image_view_); | 352 EXPECT_TRUE(NULL == notification_view()->image_view_); |
| 339 } | 353 } |
| 340 | 354 |
| 341 TEST_F(NotificationViewTest, TestLineLimits) { | 355 TEST_F(NotificationViewTest, TestLineLimits) { |
| 342 notification()->set_image(CreateTestImage(0, 0)); | 356 notification()->set_image(CreateTestImage(0, 0)); |
| 343 notification()->set_context_message(base::ASCIIToUTF16("")); | 357 notification()->set_context_message(base::ASCIIToUTF16("")); |
| 344 notification_view()->CreateOrUpdateViews(*notification()); | 358 notification_view()->UpdateWithNotification(*notification()); |
| 345 | 359 |
| 346 EXPECT_EQ(5, notification_view()->GetMessageLineLimit(0, 360)); | 360 EXPECT_EQ(5, notification_view()->GetMessageLineLimit(0, 360)); |
| 347 EXPECT_EQ(5, notification_view()->GetMessageLineLimit(1, 360)); | 361 EXPECT_EQ(5, notification_view()->GetMessageLineLimit(1, 360)); |
| 348 EXPECT_EQ(3, notification_view()->GetMessageLineLimit(2, 360)); | 362 EXPECT_EQ(3, notification_view()->GetMessageLineLimit(2, 360)); |
| 349 | 363 |
| 350 notification()->set_image(CreateTestImage(2, 2)); | 364 notification()->set_image(CreateTestImage(2, 2)); |
| 351 notification_view()->CreateOrUpdateViews(*notification()); | 365 notification_view()->UpdateWithNotification(*notification()); |
| 352 | 366 |
| 353 EXPECT_EQ(2, notification_view()->GetMessageLineLimit(0, 360)); | 367 EXPECT_EQ(2, notification_view()->GetMessageLineLimit(0, 360)); |
| 354 EXPECT_EQ(2, notification_view()->GetMessageLineLimit(1, 360)); | 368 EXPECT_EQ(2, notification_view()->GetMessageLineLimit(1, 360)); |
| 355 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(2, 360)); | 369 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(2, 360)); |
| 356 | 370 |
| 357 notification()->set_context_message(base::ASCIIToUTF16("foo")); | 371 notification()->set_context_message(base::ASCIIToUTF16("foo")); |
| 358 notification_view()->CreateOrUpdateViews(*notification()); | 372 notification_view()->UpdateWithNotification(*notification()); |
| 359 | 373 |
| 360 EXPECT_TRUE(notification_view()->context_message_view_ != NULL); | 374 EXPECT_TRUE(notification_view()->context_message_view_ != NULL); |
| 361 | 375 |
| 362 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(0, 360)); | 376 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(0, 360)); |
| 363 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(1, 360)); | 377 EXPECT_EQ(1, notification_view()->GetMessageLineLimit(1, 360)); |
| 364 EXPECT_EQ(0, notification_view()->GetMessageLineLimit(2, 360)); | 378 EXPECT_EQ(0, notification_view()->GetMessageLineLimit(2, 360)); |
| 365 } | 379 } |
| 366 | 380 |
| 367 TEST_F(NotificationViewTest, TestIconSizing) { | 381 TEST_F(NotificationViewTest, TestIconSizing) { |
| 368 notification()->set_type(NOTIFICATION_TYPE_SIMPLE); | 382 notification()->set_type(NOTIFICATION_TYPE_SIMPLE); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 paint_size = GetImagePaintSize(view); | 455 paint_size = GetImagePaintSize(view); |
| 442 EXPECT_EQ(GetImageSizeForContainerSize(container_size, orig_size).ToString(), | 456 EXPECT_EQ(GetImageSizeForContainerSize(container_size, orig_size).ToString(), |
| 443 paint_size.ToString()); | 457 paint_size.ToString()); |
| 444 ASSERT_GT(paint_size.height(), 0); | 458 ASSERT_GT(paint_size.height(), 0); |
| 445 EXPECT_EQ(orig_size.width() / orig_size.height(), | 459 EXPECT_EQ(orig_size.width() / orig_size.height(), |
| 446 paint_size.width() / paint_size.height()); | 460 paint_size.width() / paint_size.height()); |
| 447 } | 461 } |
| 448 | 462 |
| 449 TEST_F(NotificationViewTest, UpdateButtonsStateTest) { | 463 TEST_F(NotificationViewTest, UpdateButtonsStateTest) { |
| 450 notification()->set_buttons(CreateButtons(2)); | 464 notification()->set_buttons(CreateButtons(2)); |
| 451 notification_view()->CreateOrUpdateViews(*notification()); | 465 notification_view()->UpdateWithNotification(*notification()); |
| 452 widget()->Show(); | 466 widget()->Show(); |
| 453 | 467 |
| 454 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 468 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 455 notification_view()->action_buttons_[0]->state()); | 469 notification_view()->action_buttons_[0]->state()); |
| 456 | 470 |
| 457 // Now construct a mouse move event 1 pixel inside the boundary of the action | 471 // Now construct a mouse move event 1 pixel inside the boundary of the action |
| 458 // button. | 472 // button. |
| 459 gfx::Point cursor_location(1, 1); | 473 gfx::Point cursor_location(1, 1); |
| 460 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], | 474 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], |
| 461 &cursor_location); | 475 &cursor_location); |
| 462 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 476 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 463 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 477 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 464 widget()->OnMouseEvent(&move); | 478 widget()->OnMouseEvent(&move); |
| 465 | 479 |
| 466 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 480 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| 467 notification_view()->action_buttons_[0]->state()); | 481 notification_view()->action_buttons_[0]->state()); |
| 468 | 482 |
| 469 notification_view()->CreateOrUpdateViews(*notification()); | 483 notification_view()->UpdateWithNotification(*notification()); |
| 470 | 484 |
| 471 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 485 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| 472 notification_view()->action_buttons_[0]->state()); | 486 notification_view()->action_buttons_[0]->state()); |
| 473 | 487 |
| 474 // Now construct a mouse move event 1 pixel outside the boundary of the | 488 // Now construct a mouse move event 1 pixel outside the boundary of the |
| 475 // widget. | 489 // widget. |
| 476 cursor_location = gfx::Point(-1, -1); | 490 cursor_location = gfx::Point(-1, -1); |
| 477 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 491 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 478 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 492 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 479 widget()->OnMouseEvent(&move); | 493 widget()->OnMouseEvent(&move); |
| 480 | 494 |
| 481 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 495 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 482 notification_view()->action_buttons_[0]->state()); | 496 notification_view()->action_buttons_[0]->state()); |
| 483 } | 497 } |
| 484 | 498 |
| 485 TEST_F(NotificationViewTest, UpdateButtonCountTest) { | 499 TEST_F(NotificationViewTest, UpdateButtonCountTest) { |
| 486 notification()->set_buttons(CreateButtons(2)); | 500 notification()->set_buttons(CreateButtons(2)); |
| 487 notification_view()->CreateOrUpdateViews(*notification()); | 501 notification_view()->UpdateWithNotification(*notification()); |
| 488 widget()->Show(); | 502 widget()->Show(); |
| 489 | 503 |
| 490 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 504 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 491 notification_view()->action_buttons_[0]->state()); | 505 notification_view()->action_buttons_[0]->state()); |
| 492 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 506 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 493 notification_view()->action_buttons_[1]->state()); | 507 notification_view()->action_buttons_[1]->state()); |
| 494 | 508 |
| 495 // Now construct a mouse move event 1 pixel inside the boundary of the action | 509 // Now construct a mouse move event 1 pixel inside the boundary of the action |
| 496 // button. | 510 // button. |
| 497 gfx::Point cursor_location(1, 1); | 511 gfx::Point cursor_location(1, 1); |
| 498 views::View::ConvertPointToScreen(notification_view()->action_buttons_[0], | 512 views::View::ConvertPointToScreen(notification_view()->action_buttons_[0], |
| 499 &cursor_location); | 513 &cursor_location); |
| 500 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 514 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 501 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 515 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 502 ui::EventDispatchDetails details = | 516 ui::EventDispatchDetails details = |
| 503 views::test::WidgetTest::GetEventSink(widget())->OnEventFromSource(&move); | 517 views::test::WidgetTest::GetEventSink(widget())->OnEventFromSource(&move); |
| 504 EXPECT_FALSE(details.dispatcher_destroyed); | 518 EXPECT_FALSE(details.dispatcher_destroyed); |
| 505 | 519 |
| 506 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 520 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| 507 notification_view()->action_buttons_[0]->state()); | 521 notification_view()->action_buttons_[0]->state()); |
| 508 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 522 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 509 notification_view()->action_buttons_[1]->state()); | 523 notification_view()->action_buttons_[1]->state()); |
| 510 | 524 |
| 511 notification()->set_buttons(CreateButtons(1)); | 525 notification()->set_buttons(CreateButtons(1)); |
| 512 notification_view()->CreateOrUpdateViews(*notification()); | 526 notification_view()->UpdateWithNotification(*notification()); |
| 513 | 527 |
| 514 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 528 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
| 515 notification_view()->action_buttons_[0]->state()); | 529 notification_view()->action_buttons_[0]->state()); |
| 516 EXPECT_EQ(1u, notification_view()->action_buttons_.size()); | 530 EXPECT_EQ(1u, notification_view()->action_buttons_.size()); |
| 517 | 531 |
| 518 // Now construct a mouse move event 1 pixel outside the boundary of the | 532 // Now construct a mouse move event 1 pixel outside the boundary of the |
| 519 // widget. | 533 // widget. |
| 520 cursor_location = gfx::Point(-1, -1); | 534 cursor_location = gfx::Point(-1, -1); |
| 521 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 535 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 522 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 536 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 523 widget()->OnMouseEvent(&move); | 537 widget()->OnMouseEvent(&move); |
| 524 | 538 |
| 525 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 539 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
| 526 notification_view()->action_buttons_[0]->state()); | 540 notification_view()->action_buttons_[0]->state()); |
| 527 } | 541 } |
| 528 | 542 |
| 529 TEST_F(NotificationViewTest, SettingsButtonTest) { | 543 TEST_F(NotificationViewTest, SettingsButtonTest) { |
| 530 scoped_refptr<NotificationSettingsDelegate> delegate = | 544 scoped_refptr<NotificationSettingsDelegate> delegate = |
| 531 new NotificationSettingsDelegate(); | 545 new NotificationSettingsDelegate(); |
| 532 Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, | 546 Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, |
| 533 std::string("notification id"), base::UTF8ToUTF16("title"), | 547 std::string("notification id"), base::UTF8ToUTF16("title"), |
| 534 base::UTF8ToUTF16("message"), CreateTestImage(80, 80), | 548 base::UTF8ToUTF16("message"), CreateTestImage(80, 80), |
| 535 base::UTF8ToUTF16("display source"), | 549 base::UTF8ToUTF16("display source"), |
| 536 GURL("https://hello.com"), | 550 GURL("https://hello.com"), |
| 537 NotifierId(NotifierId::APPLICATION, "extension_id"), | 551 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 538 *data(), delegate.get()); | 552 *data(), delegate.get()); |
| 539 notification_view()->CreateOrUpdateViews(notf); | 553 notification_view()->UpdateWithNotification(notf); |
| 540 widget()->Show(); | 554 widget()->Show(); |
| 541 notification_view()->Layout(); | |
| 542 | 555 |
| 543 EXPECT_TRUE(NULL != notification_view()->settings_button_view_); | 556 EXPECT_TRUE(NULL != GetSettingsButton()); |
| 544 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 557 EXPECT_EQ(views::CustomButton::STATE_NORMAL, GetSettingsButton()->state()); |
| 545 notification_view()->settings_button_view_->state()); | |
| 546 | 558 |
| 547 // Now construct a mouse move event 1 pixel inside the boundary of the action | 559 // Now construct a mouse move event 1 pixel inside the boundary of the action |
| 548 // button. | 560 // button. |
| 549 gfx::Point cursor_location(1, 1); | 561 gfx::Point cursor_location(1, 1); |
| 550 views::View::ConvertPointToScreen(notification_view()->settings_button_view_, | 562 views::View::ConvertPointToScreen(GetSettingsButton(), &cursor_location); |
| 551 &cursor_location); | |
| 552 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 563 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 553 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 564 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 554 widget()->OnMouseEvent(&move); | 565 widget()->OnMouseEvent(&move); |
| 555 ui::EventDispatchDetails details = | 566 ui::EventDispatchDetails details = |
| 556 views::test::WidgetTest::GetEventSink(widget())->OnEventFromSource(&move); | 567 views::test::WidgetTest::GetEventSink(widget())->OnEventFromSource(&move); |
| 557 EXPECT_FALSE(details.dispatcher_destroyed); | 568 EXPECT_FALSE(details.dispatcher_destroyed); |
| 558 | 569 |
| 559 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 570 EXPECT_EQ(views::CustomButton::STATE_HOVERED, GetSettingsButton()->state()); |
| 560 notification_view()->settings_button_view_->state()); | |
| 561 | 571 |
| 562 // Now construct a mouse move event 1 pixel outside the boundary of the | 572 // Now construct a mouse move event 1 pixel outside the boundary of the |
| 563 // widget. | 573 // widget. |
| 564 cursor_location = gfx::Point(-1, -1); | 574 cursor_location = gfx::Point(-1, -1); |
| 565 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 575 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 566 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 576 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 567 widget()->OnMouseEvent(&move); | 577 widget()->OnMouseEvent(&move); |
| 568 | 578 |
| 569 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 579 EXPECT_EQ(views::CustomButton::STATE_NORMAL, GetSettingsButton()->state()); |
| 570 notification_view()->settings_button_view_->state()); | |
| 571 } | 580 } |
| 572 | 581 |
| 573 TEST_F(NotificationViewTest, ViewOrderingTest) { | 582 TEST_F(NotificationViewTest, ViewOrderingTest) { |
| 574 // Tests that views are created in the correct vertical order. | 583 // Tests that views are created in the correct vertical order. |
| 575 notification()->set_buttons(CreateButtons(2)); | 584 notification()->set_buttons(CreateButtons(2)); |
| 576 | 585 |
| 577 // Layout the initial views. | 586 // Layout the initial views. |
| 578 UpdateNotificationViews(); | 587 UpdateNotificationViews(); |
| 579 | 588 |
| 580 // Double-check that vertical order is correct. | 589 // Double-check that vertical order is correct. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 TEST_F(NotificationViewTest, Pinned) { | 736 TEST_F(NotificationViewTest, Pinned) { |
| 728 notification()->set_pinned(true); | 737 notification()->set_pinned(true); |
| 729 | 738 |
| 730 UpdateNotificationViews(); | 739 UpdateNotificationViews(); |
| 731 EXPECT_EQ(NULL, GetCloseButton()); | 740 EXPECT_EQ(NULL, GetCloseButton()); |
| 732 } | 741 } |
| 733 | 742 |
| 734 #endif // defined(OS_CHROMEOS) | 743 #endif // defined(OS_CHROMEOS) |
| 735 | 744 |
| 736 } // namespace message_center | 745 } // namespace message_center |
| OLD | NEW |