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 } |
| 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 return tray_view_; |
| 40 } |
| 41 |
| 42 views::View* TestSystemTrayItem::CreateDefaultView(LoginStatus status) { |
| 43 if (!has_views_) { |
| 44 default_view_ = nullptr; |
| 45 return default_view_; |
| 46 } |
| 47 default_view_ = new views::View; |
| 48 default_view_->SetLayoutManager(new views::FillLayout); |
| 49 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); |
| 50 default_view_->SetVisible(views_are_visible_); |
| 51 return default_view_; |
| 52 } |
| 53 |
| 54 views::View* TestSystemTrayItem::CreateDetailedView(LoginStatus status) { |
| 55 if (!has_views_) { |
| 56 detailed_view_ = nullptr; |
| 57 return detailed_view_; |
| 58 } |
| 59 detailed_view_ = new views::View; |
| 60 detailed_view_->SetLayoutManager(new views::FillLayout); |
| 61 detailed_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Detailed"))); |
| 62 detailed_view_->SetVisible(views_are_visible_); |
| 63 return detailed_view_; |
| 64 } |
| 65 |
| 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() { |
| 77 tray_view_ = nullptr; |
| 78 } |
| 79 |
| 80 void TestSystemTrayItem::DestroyDefaultView() { |
| 81 default_view_ = nullptr; |
| 82 } |
| 83 |
| 84 void TestSystemTrayItem::DestroyDetailedView() { |
| 85 detailed_view_ = nullptr; |
| 86 } |
| 87 |
| 88 void TestSystemTrayItem::DestroyNotificationView() { |
| 89 notification_view_ = nullptr; |
| 90 } |
| 91 |
| 92 void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 93 |
| 94 } // namespace test |
| 95 } // namespace ash |
OLD | NEW |