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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/networking_config_delegate_chromeos_browsertest.cc
diff --git a/chrome/browser/ui/ash/networking_config_delegate_chromeos_browsertest.cc b/chrome/browser/ui/ash/networking_config_delegate_chromeos_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f137a932ae349a39f03674c0d052ee7fa7cdef55
--- /dev/null
+++ b/chrome/browser/ui/ash/networking_config_delegate_chromeos_browsertest.cc
@@ -0,0 +1,79 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h"
+
+#include "ash/common/login_status.h"
+#include "ash/common/strings/grit/ash_strings.h"
+#include "ash/common/system/chromeos/network/network_detailed_view.h"
+#include "ash/common/system/chromeos/network/tray_network.h"
+#include "ash/common/system/tray/system_tray.h"
+#include "ash/common/wm_root_window_controller.h"
+#include "ash/common/wm_shell.h"
+#include "base/macros.h"
+#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "content/public/test/test_utils.h"
+#include "extensions/test/extension_test_message_listener.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/view.h"
+
+namespace {
+
+// Returns true if this view or any child view has the given tooltip.
+bool HasChildWithTooltip(views::View* view,
+ const base::string16& given_tooltip) {
+ base::string16 tooltip;
+ view->GetTooltipText(gfx::Point(), &tooltip);
+ if (tooltip == given_tooltip)
+ return true;
+
+ for (int i = 0; i < view->child_count(); ++i) {
+ if (HasChildWithTooltip(view->child_at(i), given_tooltip))
+ return true;
+ }
+
+ return false;
+}
+
+using NetworkingConfigDelegateChromeosTest = ExtensionBrowserTest;
+
+// Tests that an extension registering itself as handling a Wi-Fi SSID updates
+// the ash system tray network item.
+IN_PROC_BROWSER_TEST_F(NetworkingConfigDelegateChromeosTest, SystemTrayItem) {
+ // Load the extension and wait for the background page script to run. This
+ // registers the extension as the network config handler for wifi1.
+ ExtensionTestMessageListener listener("done", false);
+ ASSERT_TRUE(
+ LoadExtension(test_data_dir_.AppendASCII("networking_config_delegate")));
+ ASSERT_TRUE(listener.WaitUntilSatisfied());
+
+ // Open the system tray menu.
+ ash::SystemTray* system_tray =
+ ash::WmShell::Get()->GetPrimaryRootWindowController()->GetSystemTray();
+ system_tray->ShowDefaultView(ash::BUBBLE_CREATE_NEW);
+ content::RunAllPendingInMessageLoop();
+ ASSERT_TRUE(system_tray->HasSystemBubble());
+
+ // Show the network detail view.
+ ash::TrayNetwork* tray_network = system_tray->GetTrayNetworkForTesting();
+ system_tray->ShowDetailedView(tray_network, 0, false, ash::BUBBLE_CREATE_NEW);
+ content::RunAllPendingInMessageLoop();
+ ASSERT_TRUE(tray_network->detailed());
+
+ // Look for an item with a tooltip saying it is an extension-controlled
+ // network. Searching all children allows this test to avoid knowing about the
+ // specifics of the view hierarchy.
+ base::string16 expected_tooltip = l10n_util::GetStringFUTF16(
+ IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI,
+ base::UTF8ToUTF16("NetworkingConfigDelegate test extension"));
+ EXPECT_TRUE(HasChildWithTooltip(tray_network->detailed(), expected_tooltip));
+
+ // Close the system tray menu.
+ system_tray->CloseSystemBubble();
+ content::RunAllPendingInMessageLoop();
+}
+
+} // namespace
« 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