Index: ash/test/test_system_tray_item.cc |
diff --git a/ash/test/test_system_tray_item.cc b/ash/test/test_system_tray_item.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4d2cc22637423a3cb908d69469ff71ca8743d725 |
--- /dev/null |
+++ b/ash/test/test_system_tray_item.cc |
@@ -0,0 +1,92 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ash/test/test_system_tray_item.h" |
+ |
+#include "ash/test/ash_test_base.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "ui/views/controls/label.h" |
+#include "ui/views/layout/fill_layout.h" |
+#include "ui/views/view.h" |
+ |
+namespace ash { |
+namespace test { |
+ |
+TestSystemTrayItem::TestSystemTrayItem(bool has_views) |
+ : SystemTrayItem(AshTestBase::GetPrimarySystemTray(), TEST), |
+ has_views_(has_views), |
+ views_are_visible_(true), |
+ tray_view_(nullptr), |
+ default_view_(nullptr), |
+ detailed_view_(nullptr), |
+ notification_view_(nullptr) {} |
+ |
+views::View* TestSystemTrayItem::CreateTrayView(LoginStatus status) { |
+ if (!has_views_) { |
+ tray_view_ = nullptr; |
James Cook
2016/07/20 20:13:49
nit: early return
|
+ } else { |
+ tray_view_ = new views::View; |
+ // Add a label so it has non-zero width. |
+ tray_view_->SetLayoutManager(new views::FillLayout); |
+ tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); |
+ tray_view_->SetVisible(views_are_visible_); |
+ } |
+ return tray_view_; |
+} |
+ |
+views::View* TestSystemTrayItem::CreateDefaultView(LoginStatus status) { |
+ if (!has_views_) { |
+ default_view_ = nullptr; |
James Cook
2016/07/20 20:13:49
nit: early return
|
+ } else { |
+ default_view_ = new views::View; |
+ default_view_->SetLayoutManager(new views::FillLayout); |
+ default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); |
+ default_view_->SetVisible(views_are_visible_); |
+ } |
+ return default_view_; |
+} |
+ |
+views::View* TestSystemTrayItem::CreateDetailedView(LoginStatus status) { |
+ if (!has_views_) { |
+ detailed_view_ = nullptr; |
James Cook
2016/07/20 20:13:49
ditto and below
bruthig
2016/07/21 14:34:58
Done.
|
+ } else { |
+ detailed_view_ = new views::View; |
+ detailed_view_->SetLayoutManager(new views::FillLayout); |
+ detailed_view_->AddChildView( |
+ new views::Label(base::UTF8ToUTF16("Detailed"))); |
+ detailed_view_->SetVisible(views_are_visible_); |
+ } |
+ return detailed_view_; |
+} |
+ |
+views::View* TestSystemTrayItem::CreateNotificationView(LoginStatus status) { |
+ if (!has_views_) { |
+ notification_view_ = nullptr; |
+ } else { |
+ notification_view_ = new views::View; |
+ notification_view_->SetVisible(views_are_visible_); |
+ } |
+ return notification_view_; |
+} |
+ |
+void TestSystemTrayItem::DestroyTrayView() { |
+ tray_view_ = nullptr; |
+} |
+ |
+void TestSystemTrayItem::DestroyDefaultView() { |
+ default_view_ = nullptr; |
+} |
+ |
+void TestSystemTrayItem::DestroyDetailedView() { |
+ detailed_view_ = nullptr; |
+} |
+ |
+void TestSystemTrayItem::DestroyNotificationView() { |
+ notification_view_ = nullptr; |
+} |
+ |
+void TestSystemTrayItem::UpdateAfterLoginStatusChange(LoginStatus status) {} |
+ |
+} // namespace test |
+} // namespace ash |
James Cook
2016/07/20 20:13:49
Thanks for pulling this out into its own class. Mu
|