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

Unified Diff: ash/common/system/tray/tray_details_view_unittest.cc

Issue 2289223002: Make TrayDetailsView a ViewClickListener and ButtonListener (Closed)
Patch Set: fix test Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | ash/common/system/tray/view_click_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_details_view_unittest.cc
diff --git a/ash/common/system/tray/tray_details_view_unittest.cc b/ash/common/system/tray/tray_details_view_unittest.cc
index 42c4efb7974dd7792f5d3538de2c4c09ca1523f6..9fe3bbcc04e35c02c002b6b7eba652e6c8c037ad 100644
--- a/ash/common/system/tray/tray_details_view_unittest.cc
+++ b/ash/common/system/tray/tray_details_view_unittest.cc
@@ -4,6 +4,7 @@
#include "ash/common/system/tray/tray_details_view.h"
+#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/system/tray/hover_highlight_view.h"
#include "ash/common/system/tray/special_popup_row.h"
#include "ash/common/system/tray/system_tray.h"
@@ -24,21 +25,12 @@ namespace test {
namespace {
-class TestDetailsView : public TrayDetailsView,
- public ViewClickListener,
- public views::ButtonListener {
+class TestDetailsView : public TrayDetailsView {
public:
explicit TestDetailsView(SystemTrayItem* owner) : TrayDetailsView(owner) {
// Uses bluetooth label for testing purpose. It can be changed to any
// string_id.
- CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
- tray_popup_header_button_ =
- new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
- IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED,
- IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER,
- IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER,
- IDS_ASH_STATUS_TRAY_BLUETOOTH);
- footer()->AddButton(tray_popup_header_button_);
+ CreateTitleRow(IDS_ASH_STATUS_TRAY_BLUETOOTH);
}
~TestDetailsView() override {}
@@ -47,13 +39,23 @@ class TestDetailsView : public TrayDetailsView,
return tray_popup_header_button_;
}
- void FocusFooter() { footer()->content()->RequestFocus(); }
+ void FocusTitleRow() { title_row()->content()->RequestFocus(); }
- // ViewClickListener:
- void OnViewClicked(views::View* sender) override {}
+ // TrayDetailsView:
+ void CreateExtraTitleRowButtons() override {
+ // TODO(tdanderson): Add test coverage for material design buttons in the
+ // title row once they are implemented.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ return;
- // views::ButtonListener:
- void ButtonPressed(views::Button* sender, const ui::Event& event) override {}
+ tray_popup_header_button_ =
+ new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
+ IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED,
+ IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER,
+ IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER,
+ IDS_ASH_STATUS_TRAY_BLUETOOTH);
+ title_row()->AddButton(tray_popup_header_button_);
+ }
private:
TrayPopupHeaderButton* tray_popup_header_button_;
@@ -117,7 +119,7 @@ class TrayDetailsViewTest : public AshTestBase {
RunAllPendingInMessageLoop();
return static_cast<HoverHighlightView*>(
- test_item->detailed_view()->footer()->content());
+ test_item->detailed_view()->title_row()->content());
}
TrayPopupHeaderButton* CreateAndShowTrayPopupHeaderButton() {
@@ -132,6 +134,10 @@ class TrayDetailsViewTest : public AshTestBase {
return test_item->detailed_view()->tray_popup_header_button();
}
+ void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) {
+ detailed->TransitionToDefaultView();
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest);
};
@@ -161,8 +167,8 @@ TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
// Transition back to default view, the default view of item 2 should have
// focus.
- test_item_2->detailed_view()->FocusFooter();
- test_item_2->detailed_view()->TransitionToDefaultView();
+ test_item_2->detailed_view()->FocusTitleRow();
+ TransitionFromDetailedToDefaultView(test_item_2->detailed_view());
RunAllPendingInMessageLoop();
EXPECT_TRUE(test_item_2->default_view());
@@ -177,7 +183,7 @@ TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
// Transition back to default view, the default view of item 2 should NOT have
// focus.
- test_item_2->detailed_view()->TransitionToDefaultView();
+ TransitionFromDetailedToDefaultView(test_item_2->detailed_view());
RunAllPendingInMessageLoop();
EXPECT_TRUE(test_item_2->default_view());
@@ -194,9 +200,6 @@ TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedback) {
generator.set_current_location(view->GetBoundsInScreen().CenterPoint());
generator.PressTouch();
EXPECT_TRUE(view->hover());
-
- generator.ReleaseTouch();
- EXPECT_FALSE(view->hover());
}
// Tests that touch events leaving HoverHighlightView cancel the hover state.
@@ -221,6 +224,10 @@ TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedbackCancellation) {
// Tests that TrayPopupHeaderButton renders a background in response to touch.
TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedback) {
+ // Material design detailed views will not use TrayPopupHeaderButton.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ return;
+
TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton();
EXPECT_FALSE(button->background());
@@ -236,6 +243,10 @@ TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedback) {
// Tests that touch events leaving TrayPopupHeaderButton cancel the touch
// feedback background.
TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedbackCancellation) {
+ // Material design detailed views will not use TrayPopupHeaderButton.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ return;
+
TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton();
EXPECT_FALSE(button->background());
@@ -257,6 +268,10 @@ TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedbackCancellation) {
// Tests that a mouse entering TrayPopupHeaderButton renders a background as
// visual feedback.
TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonMouseHoverFeedback) {
+ // Material design detailed views will not use TrayPopupHeaderButton.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ return;
+
TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton();
EXPECT_FALSE(button->background());
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | ash/common/system/tray/view_click_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698