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

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

Issue 2563943002: Revert of Add test for system tray network menu icon for extension-controlled networks (Closed)
Patch Set: 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/tray_network.h"
10 #include "ash/common/system/tray/system_tray.h"
11 #include "ash/common/wm_root_window_controller.h"
12 #include "ash/common/wm_shell.h"
13 #include "base/macros.h"
14 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/extensions/extension_browsertest.h"
17 #include "content/public/test/test_utils.h"
18 #include "extensions/test/extension_test_message_listener.h"
19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/views/view.h"
21
22 namespace {
23
24 // Returns true if this view or any child view has the given tooltip.
25 bool HasChildWithTooltip(views::View* view,
26 const base::string16& given_tooltip) {
27 base::string16 tooltip;
28 view->GetTooltipText(gfx::Point(), &tooltip);
29 if (tooltip == given_tooltip)
30 return true;
31
32 for (int i = 0; i < view->child_count(); ++i) {
33 if (HasChildWithTooltip(view->child_at(i), given_tooltip))
34 return true;
35 }
36
37 return false;
38 }
39
40 using NetworkingConfigDelegateChromeosTest = ExtensionBrowserTest;
41
42 // Tests that an extension registering itself as handling a Wi-Fi SSID updates
43 // the ash system tray network item.
44 IN_PROC_BROWSER_TEST_F(NetworkingConfigDelegateChromeosTest, SystemTrayItem) {
45 // Load the extension and wait for the background page script to run. This
46 // registers the extension as the network config handler for wifi1.
47 ExtensionTestMessageListener listener("done", false);
48 ASSERT_TRUE(
49 LoadExtension(test_data_dir_.AppendASCII("networking_config_delegate")));
50 ASSERT_TRUE(listener.WaitUntilSatisfied());
51
52 // Simulate opening the networking details menu.
53 ash::TrayNetwork* tray_network = ash::WmShell::Get()
54 ->GetPrimaryRootWindowController()
55 ->GetSystemTray()
56 ->GetTrayNetworkForTesting();
57 std::unique_ptr<views::View> detailed_view(
58 tray_network->CreateDetailedView(ash::LoginStatus::OWNER));
59
60 // Look for an item with a tooltip saying it is an extension-controlled
61 // network. Searching all children allows this test to avoid knowing about the
62 // specifics of the view hierarchy.
63 base::string16 expected_tooltip = l10n_util::GetStringFUTF16(
64 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI,
65 base::UTF8ToUTF16("NetworkingConfigDelegate test extension"));
66 EXPECT_TRUE(HasChildWithTooltip(detailed_view.get(), expected_tooltip));
67 }
68
69 } // 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