| 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
|
|
|