OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test/test_system_tray_item.h" | 5 #include "ash/test/test_system_tray_item.h" |
6 | 6 |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "ui/views/controls/label.h" | 9 #include "ui/views/controls/label.h" |
10 #include "ui/views/layout/fill_layout.h" | 10 #include "ui/views/layout/fill_layout.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 TestSystemTrayItem::TestSystemTrayItem() : TestSystemTrayItem(UMA_TEST) {} | 16 TestSystemTrayItem::TestSystemTrayItem() : TestSystemTrayItem(UMA_TEST) {} |
17 | 17 |
18 TestSystemTrayItem::TestSystemTrayItem(SystemTrayItem::UmaType uma_type) | 18 TestSystemTrayItem::TestSystemTrayItem(SystemTrayItem::UmaType uma_type) |
19 : SystemTrayItem(AshTestBase::GetPrimarySystemTray(), uma_type), | 19 : SystemTrayItem(AshTestBase::GetPrimarySystemTray(), uma_type), |
20 has_views_(true), | 20 has_views_(true), |
21 views_are_visible_(true), | 21 views_are_visible_(true), |
22 tray_view_(nullptr), | 22 tray_view_(nullptr), |
23 default_view_(nullptr), | 23 default_view_(nullptr), |
24 detailed_view_(nullptr), | 24 detailed_view_(nullptr) {} |
25 notification_view_(nullptr) {} | |
26 | 25 |
27 TestSystemTrayItem::~TestSystemTrayItem() {} | 26 TestSystemTrayItem::~TestSystemTrayItem() {} |
28 | 27 |
29 views::View* TestSystemTrayItem::CreateTrayView(LoginStatus status) { | 28 views::View* TestSystemTrayItem::CreateTrayView(LoginStatus status) { |
30 if (!has_views_) { | 29 if (!has_views_) { |
31 tray_view_ = nullptr; | 30 tray_view_ = nullptr; |
32 return tray_view_; | 31 return tray_view_; |
33 } | 32 } |
34 tray_view_ = new views::View; | 33 tray_view_ = new views::View; |
35 // Add a label so it has non-zero width. | 34 // Add a label so it has non-zero width. |
(...skipping 20 matching lines...) Expand all Loading... |
56 detailed_view_ = nullptr; | 55 detailed_view_ = nullptr; |
57 return detailed_view_; | 56 return detailed_view_; |
58 } | 57 } |
59 detailed_view_ = new views::View; | 58 detailed_view_ = new views::View; |
60 detailed_view_->SetLayoutManager(new views::FillLayout); | 59 detailed_view_->SetLayoutManager(new views::FillLayout); |
61 detailed_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Detailed"))); | 60 detailed_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Detailed"))); |
62 detailed_view_->SetVisible(views_are_visible_); | 61 detailed_view_->SetVisible(views_are_visible_); |
63 return detailed_view_; | 62 return detailed_view_; |
64 } | 63 } |
65 | 64 |
66 views::View* TestSystemTrayItem::CreateNotificationView(LoginStatus status) { | |
67 if (!has_views_) { | |
68 notification_view_ = nullptr; | |
69 return notification_view_; | |
70 } | |
71 notification_view_ = new views::View; | |
72 notification_view_->SetVisible(views_are_visible_); | |
73 return notification_view_; | |
74 } | |
75 | |
76 void TestSystemTrayItem::DestroyTrayView() { | 65 void TestSystemTrayItem::DestroyTrayView() { |
77 tray_view_ = nullptr; | 66 tray_view_ = nullptr; |
78 } | 67 } |
79 | 68 |
80 void TestSystemTrayItem::DestroyDefaultView() { | 69 void TestSystemTrayItem::DestroyDefaultView() { |
81 default_view_ = nullptr; | 70 default_view_ = nullptr; |
82 } | 71 } |
83 | 72 |
84 void TestSystemTrayItem::DestroyDetailedView() { | 73 void TestSystemTrayItem::DestroyDetailedView() { |
85 detailed_view_ = nullptr; | 74 detailed_view_ = nullptr; |
86 } | 75 } |
87 | 76 |
88 void TestSystemTrayItem::DestroyNotificationView() { | |
89 notification_view_ = nullptr; | |
90 } | |
91 | |
92 void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} | 77 void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} |
93 | 78 |
94 } // namespace test | 79 } // namespace test |
95 } // namespace ash | 80 } // namespace ash |
OLD | NEW |