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

Side by Side Diff: chrome/browser/ui/ash/networking_config_delegate_chromeos_browsertest.cc

Issue 2565823002: Reland: Add test for system tray network menu icon for extension-controlled networks (Closed)
Patch Set: fix use-after-free Created 4 years 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 | « ash/common/system/tray/system_tray.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h"
6
7 #include "ash/common/login_status.h"
8 #include "ash/common/strings/grit/ash_strings.h"
9 #include "ash/common/system/chromeos/network/network_detailed_view.h"
10 #include "ash/common/system/chromeos/network/tray_network.h"
11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/wm_root_window_controller.h"
13 #include "ash/common/wm_shell.h"
14 #include "base/macros.h"
15 #include "base/strings/string16.h"
16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/extensions/extension_browsertest.h"
18 #include "content/public/test/test_utils.h"
19 #include "extensions/test/extension_test_message_listener.h"
20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/views/view.h"
22
23 namespace {
24
25 // Returns true if this view or any child view has the given tooltip.
26 bool HasChildWithTooltip(views::View* view,
27 const base::string16& given_tooltip) {
28 base::string16 tooltip;
29 view->GetTooltipText(gfx::Point(), &tooltip);
30 if (tooltip == given_tooltip)
31 return true;
32
33 for (int i = 0; i < view->child_count(); ++i) {
34 if (HasChildWithTooltip(view->child_at(i), given_tooltip))
35 return true;
36 }
37
38 return false;
39 }
40
41 using NetworkingConfigDelegateChromeosTest = ExtensionBrowserTest;
42
43 // Tests that an extension registering itself as handling a Wi-Fi SSID updates
44 // the ash system tray network item.
45 IN_PROC_BROWSER_TEST_F(NetworkingConfigDelegateChromeosTest, SystemTrayItem) {
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.
48 ExtensionTestMessageListener listener("done", false);
49 ASSERT_TRUE(
50 LoadExtension(test_data_dir_.AppendASCII("networking_config_delegate")));
51 ASSERT_TRUE(listener.WaitUntilSatisfied());
52
53 // Open the system tray menu.
54 ash::SystemTray* system_tray =
55 ash::WmShell::Get()->GetPrimaryRootWindowController()->GetSystemTray();
56 system_tray->ShowDefaultView(ash::BUBBLE_CREATE_NEW);
57 content::RunAllPendingInMessageLoop();
58 ASSERT_TRUE(system_tray->HasSystemBubble());
59
60 // Show the network detail view.
61 ash::TrayNetwork* tray_network = system_tray->GetTrayNetworkForTesting();
62 system_tray->ShowDetailedView(tray_network, 0, false, ash::BUBBLE_CREATE_NEW);
63 content::RunAllPendingInMessageLoop();
64 ASSERT_TRUE(tray_network->detailed());
65
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
68 // specifics of the view hierarchy.
69 base::string16 expected_tooltip = l10n_util::GetStringFUTF16(
70 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI,
71 base::UTF8ToUTF16("NetworkingConfigDelegate test extension"));
72 EXPECT_TRUE(HasChildWithTooltip(tray_network->detailed(), expected_tooltip));
73
74 // Close the system tray menu.
75 system_tray->CloseSystemBubble();
76 content::RunAllPendingInMessageLoop();
77 }
78
79 } // namespace
OLDNEW
« no previous file with comments | « ash/common/system/tray/system_tray.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698