| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/ash/networking_config_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/login_status.h" | 7 #include "ash/login_status.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell_port.h" |
| 9 #include "ash/strings/grit/ash_strings.h" | 10 #include "ash/strings/grit/ash_strings.h" |
| 10 #include "ash/system/network/network_detailed_view.h" | 11 #include "ash/system/network/network_detailed_view.h" |
| 11 #include "ash/system/network/tray_network.h" | 12 #include "ash/system/network/tray_network.h" |
| 12 #include "ash/system/tray/system_tray.h" | 13 #include "ash/system/tray/system_tray.h" |
| 13 #include "ash/wm_shell.h" | |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 19 #include "extensions/test/extension_test_message_listener.h" | 19 #include "extensions/test/extension_test_message_listener.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 IN_PROC_BROWSER_TEST_F(NetworkingConfigDelegateChromeosTest, SystemTrayItem) { | 45 IN_PROC_BROWSER_TEST_F(NetworkingConfigDelegateChromeosTest, SystemTrayItem) { |
| 46 // Load the extension and wait for the background page script to run. This | 46 // Load the extension and wait for the background page script to run. This |
| 47 // registers the extension as the network config handler for wifi1. | 47 // registers the extension as the network config handler for wifi1. |
| 48 ExtensionTestMessageListener listener("done", false); | 48 ExtensionTestMessageListener listener("done", false); |
| 49 ASSERT_TRUE( | 49 ASSERT_TRUE( |
| 50 LoadExtension(test_data_dir_.AppendASCII("networking_config_delegate"))); | 50 LoadExtension(test_data_dir_.AppendASCII("networking_config_delegate"))); |
| 51 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 51 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 52 | 52 |
| 53 // Open the system tray menu. | 53 // Open the system tray menu. |
| 54 ash::SystemTray* system_tray = | 54 ash::SystemTray* system_tray = |
| 55 ash::WmShell::Get()->GetPrimaryRootWindowController()->GetSystemTray(); | 55 ash::ShellPort::Get()->GetPrimaryRootWindowController()->GetSystemTray(); |
| 56 system_tray->ShowDefaultView(ash::BUBBLE_CREATE_NEW); | 56 system_tray->ShowDefaultView(ash::BUBBLE_CREATE_NEW); |
| 57 content::RunAllPendingInMessageLoop(); | 57 content::RunAllPendingInMessageLoop(); |
| 58 ASSERT_TRUE(system_tray->HasSystemBubble()); | 58 ASSERT_TRUE(system_tray->HasSystemBubble()); |
| 59 | 59 |
| 60 // Show the network detail view. | 60 // Show the network detail view. |
| 61 ash::TrayNetwork* tray_network = system_tray->GetTrayNetworkForTesting(); | 61 ash::TrayNetwork* tray_network = system_tray->GetTrayNetworkForTesting(); |
| 62 system_tray->ShowDetailedView(tray_network, 0, false, ash::BUBBLE_CREATE_NEW); | 62 system_tray->ShowDetailedView(tray_network, 0, false, ash::BUBBLE_CREATE_NEW); |
| 63 content::RunAllPendingInMessageLoop(); | 63 content::RunAllPendingInMessageLoop(); |
| 64 ASSERT_TRUE(tray_network->detailed()); | 64 ASSERT_TRUE(tray_network->detailed()); |
| 65 | 65 |
| 66 // Look for an item with a tooltip saying it is an extension-controlled | 66 // Look for an item with a tooltip saying it is an extension-controlled |
| 67 // network. Searching all children allows this test to avoid knowing about the | 67 // network. Searching all children allows this test to avoid knowing about the |
| 68 // specifics of the view hierarchy. | 68 // specifics of the view hierarchy. |
| 69 base::string16 expected_tooltip = l10n_util::GetStringFUTF16( | 69 base::string16 expected_tooltip = l10n_util::GetStringFUTF16( |
| 70 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI, | 70 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI, |
| 71 base::UTF8ToUTF16("NetworkingConfigDelegate test extension")); | 71 base::UTF8ToUTF16("NetworkingConfigDelegate test extension")); |
| 72 EXPECT_TRUE(HasChildWithTooltip(tray_network->detailed(), expected_tooltip)); | 72 EXPECT_TRUE(HasChildWithTooltip(tray_network->detailed(), expected_tooltip)); |
| 73 | 73 |
| 74 // Close the system tray menu. | 74 // Close the system tray menu. |
| 75 system_tray->CloseSystemBubble(); | 75 system_tray->CloseSystemBubble(); |
| 76 content::RunAllPendingInMessageLoop(); | 76 content::RunAllPendingInMessageLoop(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace | 79 } // namespace |
| OLD | NEW |