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

Side by Side Diff: ash/system/enterprise/tray_enterprise_unittest.cc

Issue 2931643002: chromeos: Introduce ash::SystemTrayTestApi (Closed)
Patch Set: review comments Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/system/network/tray_network_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/enterprise/tray_enterprise.h" 5 #include "ash/system/enterprise/tray_enterprise.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/label_tray_view.h" 8 #include "ash/system/tray/label_tray_view.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_controller.h" 10 #include "ash/system/tray/system_tray_controller.h"
11 #include "ash/system/tray/system_tray_test_api.h"
11 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
12 13
13 namespace ash { 14 namespace ash {
14 15
15 using TrayEnterpriseTest = test::AshTestBase; 16 using TrayEnterpriseTest = test::AshTestBase;
16 17
17 TEST_F(TrayEnterpriseTest, ItemVisible) { 18 TEST_F(TrayEnterpriseTest, ItemVisible) {
18 SystemTray* system_tray = GetPrimarySystemTray(); 19 SystemTray* system_tray = GetPrimarySystemTray();
19 TrayEnterprise* tray_enterprise = system_tray->GetTrayEnterpriseForTesting(); 20 TrayEnterprise* tray_enterprise =
21 SystemTrayTestApi(system_tray).tray_enterprise();
20 22
21 // By default there is no enterprise item in the menu. 23 // By default there is no enterprise item in the menu.
22 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 24 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
23 EXPECT_FALSE(tray_enterprise->tray_view()->visible()); 25 EXPECT_FALSE(tray_enterprise->tray_view()->visible());
24 system_tray->CloseSystemBubble(); 26 system_tray->CloseSystemBubble();
25 27
26 // Simulate enterprise information becoming available. 28 // Simulate enterprise information becoming available.
27 const bool active_directory = false; 29 const bool active_directory = false;
28 Shell::Get()->system_tray_controller()->SetEnterpriseDomain("example.com", 30 Shell::Get()->system_tray_controller()->SetEnterpriseDomain("example.com",
29 active_directory); 31 active_directory);
30 32
31 // Enterprise managed devices show an item. 33 // Enterprise managed devices show an item.
32 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 34 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
33 EXPECT_TRUE(tray_enterprise->tray_view()->visible()); 35 EXPECT_TRUE(tray_enterprise->tray_view()->visible());
34 system_tray->CloseSystemBubble(); 36 system_tray->CloseSystemBubble();
35 } 37 }
36 38
37 TEST_F(TrayEnterpriseTest, ItemVisibleForActiveDirectory) { 39 TEST_F(TrayEnterpriseTest, ItemVisibleForActiveDirectory) {
38 SystemTray* system_tray = GetPrimarySystemTray(); 40 SystemTray* system_tray = GetPrimarySystemTray();
39 TrayEnterprise* tray_enterprise = system_tray->GetTrayEnterpriseForTesting(); 41 TrayEnterprise* tray_enterprise =
42 SystemTrayTestApi(system_tray).tray_enterprise();
40 43
41 // Simulate enterprise information becoming available. Active Directory 44 // Simulate enterprise information becoming available. Active Directory
42 // devices do not have a domain. 45 // devices do not have a domain.
43 const std::string empty_domain; 46 const std::string empty_domain;
44 const bool active_directory = true; 47 const bool active_directory = true;
45 Shell::Get()->system_tray_controller()->SetEnterpriseDomain(empty_domain, 48 Shell::Get()->system_tray_controller()->SetEnterpriseDomain(empty_domain,
46 active_directory); 49 active_directory);
47 50
48 // Active Directory managed devices show an item. 51 // Active Directory managed devices show an item.
49 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 52 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
50 EXPECT_TRUE(tray_enterprise->tray_view()->visible()); 53 EXPECT_TRUE(tray_enterprise->tray_view()->visible());
51 system_tray->CloseSystemBubble(); 54 system_tray->CloseSystemBubble();
52 } 55 }
53 56
54 } // namespace ash 57 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/network/tray_network_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698