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(bool has_views) | |
17 : SystemTrayItem(AshTestBase::GetPrimarySystemTray(), TEST), | |
18 has_views_(has_views), | |
19 views_are_visible_(true), | |
20 tray_view_(nullptr), | |
21 default_view_(nullptr), | |
22 detailed_view_(nullptr), | |
23 notification_view_(nullptr) {} | |
24 | |
25 views::View* TestSystemTrayItem::CreateTrayView(LoginStatus status) { | |
26 if (!has_views_) { | |
27 tray_view_ = nullptr; | |
James Cook
2016/07/20 20:13:49
nit: early return
| |
28 } else { | |
29 tray_view_ = new views::View; | |
30 // Add a label so it has non-zero width. | |
31 tray_view_->SetLayoutManager(new views::FillLayout); | |
32 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); | |
33 tray_view_->SetVisible(views_are_visible_); | |
34 } | |
35 return tray_view_; | |
36 } | |
37 | |
38 views::View* TestSystemTrayItem::CreateDefaultView(LoginStatus status) { | |
39 if (!has_views_) { | |
40 default_view_ = nullptr; | |
James Cook
2016/07/20 20:13:49
nit: early return
| |
41 } else { | |
42 default_view_ = new views::View; | |
43 default_view_->SetLayoutManager(new views::FillLayout); | |
44 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | |
45 default_view_->SetVisible(views_are_visible_); | |
46 } | |
47 return default_view_; | |
48 } | |
49 | |
50 views::View* TestSystemTrayItem::CreateDetailedView(LoginStatus status) { | |
51 if (!has_views_) { | |
52 detailed_view_ = nullptr; | |
James Cook
2016/07/20 20:13:49
ditto and below
bruthig
2016/07/21 14:34:58
Done.
| |
53 } else { | |
54 detailed_view_ = new views::View; | |
55 detailed_view_->SetLayoutManager(new views::FillLayout); | |
56 detailed_view_->AddChildView( | |
57 new views::Label(base::UTF8ToUTF16("Detailed"))); | |
58 detailed_view_->SetVisible(views_are_visible_); | |
59 } | |
60 return detailed_view_; | |
61 } | |
62 | |
63 views::View* TestSystemTrayItem::CreateNotificationView(LoginStatus status) { | |
64 if (!has_views_) { | |
65 notification_view_ = nullptr; | |
66 } else { | |
67 notification_view_ = new views::View; | |
68 notification_view_->SetVisible(views_are_visible_); | |
69 } | |
70 return notification_view_; | |
71 } | |
72 | |
73 void TestSystemTrayItem::DestroyTrayView() { | |
74 tray_view_ = nullptr; | |
75 } | |
76 | |
77 void TestSystemTrayItem::DestroyDefaultView() { | |
78 default_view_ = nullptr; | |
79 } | |
80 | |
81 void TestSystemTrayItem::DestroyDetailedView() { | |
82 detailed_view_ = nullptr; | |
83 } | |
84 | |
85 void TestSystemTrayItem::DestroyNotificationView() { | |
86 notification_view_ = nullptr; | |
87 } | |
88 | |
89 void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} | |
90 | |
91 } // namespace test | |
92 } // namespace ash | |
James Cook
2016/07/20 20:13:49
Thanks for pulling this out into its own class. Mu
| |
OLD | NEW |