Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1730)

Unified Diff: ash/system/enterprise/tray_enterprise_unittest.cc

Issue 2839043004: chromeos: Refactor ash SystemTrayDelegate enterprise methods to mojo (Closed)
Patch Set: review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/enterprise/tray_enterprise.cc ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/enterprise/tray_enterprise_unittest.cc
diff --git a/ash/system/enterprise/tray_enterprise_unittest.cc b/ash/system/enterprise/tray_enterprise_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0735efa1a544293241160c17880fc6a60abce54b
--- /dev/null
+++ b/ash/system/enterprise/tray_enterprise_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 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/system/enterprise/tray_enterprise.h"
+
+#include "ash/shell.h"
+#include "ash/system/tray/label_tray_view.h"
+#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/system_tray_controller.h"
+#include "ash/test/ash_test_base.h"
+
+namespace ash {
+
+using TrayEnterpriseTest = test::AshTestBase;
+
+TEST_F(TrayEnterpriseTest, ItemVisible) {
+ SystemTray* system_tray = GetPrimarySystemTray();
+ TrayEnterprise* tray_enterprise = system_tray->GetTrayEnterpriseForTesting();
+
+ // By default there is no enterprise item in the menu.
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ EXPECT_FALSE(tray_enterprise->tray_view()->visible());
+ system_tray->CloseSystemBubble();
+
+ // Simulate enterprise information becoming available.
+ const bool active_directory = false;
+ Shell::Get()->system_tray_controller()->SetEnterpriseDomain("example.com",
+ active_directory);
+
+ // Enterprise managed devices show an item.
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ EXPECT_TRUE(tray_enterprise->tray_view()->visible());
+ system_tray->CloseSystemBubble();
+}
+
+TEST_F(TrayEnterpriseTest, ItemVisibleForActiveDirectory) {
+ SystemTray* system_tray = GetPrimarySystemTray();
+ TrayEnterprise* tray_enterprise = system_tray->GetTrayEnterpriseForTesting();
+
+ // Simulate enterprise information becoming available. Active Directory
+ // devices do not have a domain.
+ const std::string empty_domain;
+ const bool active_directory = true;
+ Shell::Get()->system_tray_controller()->SetEnterpriseDomain(empty_domain,
+ active_directory);
+
+ // Active Directory managed devices show an item.
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ EXPECT_TRUE(tray_enterprise->tray_view()->visible());
+ system_tray->CloseSystemBubble();
+}
+
+} // namespace ash
« no previous file with comments | « ash/system/enterprise/tray_enterprise.cc ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698