OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/system/tray/tray_details_view.h" | 5 #include "ash/system/tray/tray_details_view.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf_widget.h" | 8 #include "ash/shelf/shelf_widget.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 class TestDetailsView : public TrayDetailsView, public ViewClickListener { | 37 class TestDetailsView : public TrayDetailsView, public ViewClickListener { |
38 public: | 38 public: |
39 explicit TestDetailsView(SystemTrayItem* owner) : TrayDetailsView(owner) { | 39 explicit TestDetailsView(SystemTrayItem* owner) : TrayDetailsView(owner) { |
40 // Uses bluetooth label for testing purpose. It can be changed to any | 40 // Uses bluetooth label for testing purpose. It can be changed to any |
41 // string_id. | 41 // string_id. |
42 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); | 42 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); |
43 } | 43 } |
44 | 44 |
45 virtual ~TestDetailsView() {} | 45 ~TestDetailsView() override {} |
46 | 46 |
47 void FocusFooter() { | 47 void FocusFooter() { |
48 footer()->content()->RequestFocus(); | 48 footer()->content()->RequestFocus(); |
49 } | 49 } |
50 | 50 |
51 // Overridden from ViewClickListener: | 51 // Overridden from ViewClickListener: |
52 virtual void OnViewClicked(views::View* sender) override {} | 52 void OnViewClicked(views::View* sender) override {} |
53 | 53 |
54 private: | 54 private: |
55 DISALLOW_COPY_AND_ASSIGN(TestDetailsView); | 55 DISALLOW_COPY_AND_ASSIGN(TestDetailsView); |
56 }; | 56 }; |
57 | 57 |
58 // Trivial item implementation that tracks its views for testing. | 58 // Trivial item implementation that tracks its views for testing. |
59 class TestItem : public SystemTrayItem { | 59 class TestItem : public SystemTrayItem { |
60 public: | 60 public: |
61 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} | 61 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} |
62 | 62 |
63 // Overridden from SystemTrayItem: | 63 // Overridden from SystemTrayItem: |
64 virtual views::View* CreateTrayView(user::LoginStatus status) override { | 64 views::View* CreateTrayView(user::LoginStatus status) override { |
65 tray_view_ = new views::View; | 65 tray_view_ = new views::View; |
66 return tray_view_; | 66 return tray_view_; |
67 } | 67 } |
68 virtual views::View* CreateDefaultView(user::LoginStatus status) override { | 68 views::View* CreateDefaultView(user::LoginStatus status) override { |
69 default_view_ = new views::View; | 69 default_view_ = new views::View; |
70 default_view_->SetFocusable(true); | 70 default_view_->SetFocusable(true); |
71 return default_view_; | 71 return default_view_; |
72 } | 72 } |
73 virtual views::View* CreateDetailedView(user::LoginStatus status) override { | 73 views::View* CreateDetailedView(user::LoginStatus status) override { |
74 detailed_view_ = new TestDetailsView(this); | 74 detailed_view_ = new TestDetailsView(this); |
75 return detailed_view_; | 75 return detailed_view_; |
76 } | 76 } |
77 virtual void DestroyTrayView() override { | 77 void DestroyTrayView() override { tray_view_ = NULL; } |
78 tray_view_ = NULL; | 78 void DestroyDefaultView() override { default_view_ = NULL; } |
79 } | 79 void DestroyDetailedView() override { detailed_view_ = NULL; } |
80 virtual void DestroyDefaultView() override { | |
81 default_view_ = NULL; | |
82 } | |
83 virtual void DestroyDetailedView() override { | |
84 detailed_view_ = NULL; | |
85 } | |
86 | 80 |
87 views::View* tray_view() const { return tray_view_; } | 81 views::View* tray_view() const { return tray_view_; } |
88 views::View* default_view() const { return default_view_; } | 82 views::View* default_view() const { return default_view_; } |
89 TestDetailsView* detailed_view() const { return detailed_view_; } | 83 TestDetailsView* detailed_view() const { return detailed_view_; } |
90 | 84 |
91 private: | 85 private: |
92 views::View* tray_view_; | 86 views::View* tray_view_; |
93 views::View* default_view_; | 87 views::View* default_view_; |
94 TestDetailsView* detailed_view_; | 88 TestDetailsView* detailed_view_; |
95 | 89 |
96 DISALLOW_COPY_AND_ASSIGN(TestItem); | 90 DISALLOW_COPY_AND_ASSIGN(TestItem); |
97 }; | 91 }; |
98 | 92 |
99 } // namespace | 93 } // namespace |
100 | 94 |
101 class TrayDetailsViewTest : public AshTestBase { | 95 class TrayDetailsViewTest : public AshTestBase { |
102 public: | 96 public: |
103 TrayDetailsViewTest() {} | 97 TrayDetailsViewTest() {} |
104 virtual ~TrayDetailsViewTest() {} | 98 ~TrayDetailsViewTest() override {} |
105 | 99 |
106 HoverHighlightView* CreateAndShowHoverHighlightView() { | 100 HoverHighlightView* CreateAndShowHoverHighlightView() { |
107 SystemTray* tray = GetSystemTray(); | 101 SystemTray* tray = GetSystemTray(); |
108 TestItem* test_item = new TestItem; | 102 TestItem* test_item = new TestItem; |
109 tray->AddTrayItem(test_item); | 103 tray->AddTrayItem(test_item); |
110 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 104 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
111 RunAllPendingInMessageLoop(); | 105 RunAllPendingInMessageLoop(); |
112 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); | 106 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); |
113 RunAllPendingInMessageLoop(); | 107 RunAllPendingInMessageLoop(); |
114 | 108 |
115 return static_cast<HoverHighlightView*>(test_item->detailed_view()-> | 109 return static_cast<HoverHighlightView*>(test_item->detailed_view()-> |
116 footer()->content()); | 110 footer()->content()); |
117 } | 111 } |
118 | 112 |
119 virtual void SetUp() override { | 113 void SetUp() override { |
120 CommandLine::ForCurrentProcess()->AppendSwitch( | 114 CommandLine::ForCurrentProcess()->AppendSwitch( |
121 switches::kEnableTouchFeedback); | 115 switches::kEnableTouchFeedback); |
122 test::AshTestBase::SetUp(); | 116 test::AshTestBase::SetUp(); |
123 } | 117 } |
124 | 118 |
125 private: | 119 private: |
126 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); | 120 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); |
127 }; | 121 }; |
128 | 122 |
129 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { | 123 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXPECT_FALSE(view->hover()); | 203 EXPECT_FALSE(view->hover()); |
210 | 204 |
211 generator.set_current_location(move_point); | 205 generator.set_current_location(move_point); |
212 generator.ReleaseTouch(); | 206 generator.ReleaseTouch(); |
213 RunAllPendingInMessageLoop(); | 207 RunAllPendingInMessageLoop(); |
214 EXPECT_FALSE(view->hover()); | 208 EXPECT_FALSE(view->hover()); |
215 } | 209 } |
216 | 210 |
217 } // namespace test | 211 } // namespace test |
218 } // namespace ash | 212 } // namespace ash |
OLD | NEW |