OLD | NEW |
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/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
6 | 6 |
7 #include "ash/login_status.h" | 7 #include "ash/login_status.h" |
8 #include "ash/system/network/network_list.h" | 8 #include "ash/system/network/network_list.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_test_api.h" |
10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 13 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/network/network_handler.h" | 14 #include "chromeos/network/network_handler.h" |
14 #include "components/prefs/testing_pref_service.h" | 15 #include "components/prefs/testing_pref_service.h" |
15 #include "ui/message_center/message_center.h" | 16 #include "ui/message_center/message_center.h" |
16 | 17 |
17 using message_center::MessageCenter; | 18 using message_center::MessageCenter; |
18 | 19 |
19 namespace ash { | 20 namespace ash { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 }; | 53 }; |
53 | 54 |
54 // Verifies that the network views can be created. | 55 // Verifies that the network views can be created. |
55 TEST_F(TrayNetworkTest, Basics) { | 56 TEST_F(TrayNetworkTest, Basics) { |
56 // Open the system tray menu. | 57 // Open the system tray menu. |
57 SystemTray* system_tray = GetPrimarySystemTray(); | 58 SystemTray* system_tray = GetPrimarySystemTray(); |
58 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 59 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
59 RunAllPendingInMessageLoop(); | 60 RunAllPendingInMessageLoop(); |
60 | 61 |
61 // Show network details. | 62 // Show network details. |
62 TrayNetwork* tray_network = system_tray->GetTrayNetworkForTesting(); | 63 TrayNetwork* tray_network = SystemTrayTestApi(system_tray).tray_network(); |
63 const int close_delay_in_seconds = 0; | 64 const int close_delay_in_seconds = 0; |
64 bool activate = true; | 65 bool activate = true; |
65 system_tray->ShowDetailedView(tray_network, close_delay_in_seconds, activate, | 66 system_tray->ShowDetailedView(tray_network, close_delay_in_seconds, activate, |
66 BUBBLE_USE_EXISTING); | 67 BUBBLE_USE_EXISTING); |
67 RunAllPendingInMessageLoop(); | 68 RunAllPendingInMessageLoop(); |
68 | 69 |
69 // Network details view was created. | 70 // Network details view was created. |
70 ASSERT_TRUE(tray_network->detailed()); | 71 ASSERT_TRUE(tray_network->detailed()); |
71 EXPECT_TRUE(tray_network->detailed()->visible()); | 72 EXPECT_TRUE(tray_network->detailed()->visible()); |
72 } | 73 } |
73 | 74 |
74 // Verifies that toggling Wi-Fi (usually via keyboard) shows a notification. | 75 // Verifies that toggling Wi-Fi (usually via keyboard) shows a notification. |
75 TEST_F(TrayNetworkTest, ToggleWifi) { | 76 TEST_F(TrayNetworkTest, ToggleWifi) { |
76 TrayNetwork* tray_network = | 77 TrayNetwork* tray_network = |
77 GetPrimarySystemTray()->GetTrayNetworkForTesting(); | 78 SystemTrayTestApi(GetPrimarySystemTray()).tray_network(); |
78 | 79 |
79 // No notifications at startup. | 80 // No notifications at startup. |
80 ASSERT_EQ(0u, MessageCenter::Get()->NotificationCount()); | 81 ASSERT_EQ(0u, MessageCenter::Get()->NotificationCount()); |
81 | 82 |
82 // Simulate a user action to toggle Wi-Fi. | 83 // Simulate a user action to toggle Wi-Fi. |
83 tray_network->RequestToggleWifi(); | 84 tray_network->RequestToggleWifi(); |
84 | 85 |
85 // Notification was shown. | 86 // Notification was shown. |
86 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); | 87 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); |
87 EXPECT_TRUE(MessageCenter::Get()->HasPopupNotifications()); | 88 EXPECT_TRUE(MessageCenter::Get()->HasPopupNotifications()); |
88 EXPECT_TRUE(MessageCenter::Get()->FindVisibleNotificationById("wifi-toggle")); | 89 EXPECT_TRUE(MessageCenter::Get()->FindVisibleNotificationById("wifi-toggle")); |
89 } | 90 } |
90 | 91 |
91 } // namespace | 92 } // namespace |
92 } // namespace ash | 93 } // namespace ash |
OLD | NEW |