OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/test/test_system_tray_item.h" | |
6 | |
7 #include "ash/test/ash_test_base.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "ui/views/controls/label.h" | |
10 #include "ui/views/layout/fill_layout.h" | |
11 #include "ui/views/view.h" | |
12 | |
13 namespace ash { | |
14 namespace test { | |
15 | |
16 TestSystemTrayItem::TestSystemTrayItem() : TestSystemTrayItem(UMA_TEST) {} | |
17 | |
18 TestSystemTrayItem::TestSystemTrayItem(SystemTrayItem::UmaType uma_type) | |
19 : SystemTrayItem(AshTestBase::GetPrimarySystemTray(), uma_type), | |
20 has_views_(true), | |
21 views_are_visible_(true), | |
22 tray_view_(nullptr), | |
23 default_view_(nullptr), | |
24 detailed_view_(nullptr), | |
25 notification_view_(nullptr) {} | |
26 | |
27 TestSystemTrayItem::~TestSystemTrayItem() {} | |
28 | |
29 views::View* TestSystemTrayItem::CreateTrayView(LoginStatus status) { | |
30 if (!has_views_) { | |
31 tray_view_ = nullptr; | |
32 return tray_view_; | |
33 } else { | |
James Cook
2016/07/21 16:14:00
nit: no else due to early return
bruthig
2016/07/21 17:24:25
Done.
| |
34 tray_view_ = new views::View; | |
35 // Add a label so it has non-zero width. | |
36 tray_view_->SetLayoutManager(new views::FillLayout); | |
37 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); | |
38 tray_view_->SetVisible(views_are_visible_); | |
39 } | |
40 return tray_view_; | |
41 } | |
42 | |
43 views::View* TestSystemTrayItem::CreateDefaultView(LoginStatus status) { | |
44 if (!has_views_) { | |
45 default_view_ = nullptr; | |
46 return default_view_; | |
47 } else { | |
48 default_view_ = new views::View; | |
49 default_view_->SetLayoutManager(new views::FillLayout); | |
50 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | |
51 default_view_->SetVisible(views_are_visible_); | |
52 } | |
53 return default_view_; | |
54 } | |
55 | |
56 views::View* TestSystemTrayItem::CreateDetailedView(LoginStatus status) { | |
57 if (!has_views_) { | |
58 detailed_view_ = nullptr; | |
59 return detailed_view_; | |
60 } else { | |
61 detailed_view_ = new views::View; | |
62 detailed_view_->SetLayoutManager(new views::FillLayout); | |
63 detailed_view_->AddChildView( | |
64 new views::Label(base::UTF8ToUTF16("Detailed"))); | |
65 detailed_view_->SetVisible(views_are_visible_); | |
66 } | |
67 return detailed_view_; | |
68 } | |
69 | |
70 views::View* TestSystemTrayItem::CreateNotificationView(LoginStatus status) { | |
71 if (!has_views_) { | |
72 notification_view_ = nullptr; | |
73 return notification_view_; | |
74 } else { | |
75 notification_view_ = new views::View; | |
76 notification_view_->SetVisible(views_are_visible_); | |
77 } | |
78 return notification_view_; | |
79 } | |
80 | |
81 void TestSystemTrayItem::DestroyTrayView() { | |
82 tray_view_ = nullptr; | |
83 } | |
84 | |
85 void TestSystemTrayItem::DestroyDefaultView() { | |
86 default_view_ = nullptr; | |
87 } | |
88 | |
89 void TestSystemTrayItem::DestroyDetailedView() { | |
90 detailed_view_ = nullptr; | |
91 } | |
92 | |
93 void TestSystemTrayItem::DestroyNotificationView() { | |
94 notification_view_ = nullptr; | |
95 } | |
96 | |
97 void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} | |
98 | |
99 } // namespace test | |
100 } // namespace ash | |
OLD | NEW |