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

Unified Diff: chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc

Issue 818433003: ChromeOS: Implement CaptivePortalAuthenticationIgnoresProxy policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 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
Index: chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc
diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc b/chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc
index b34cf1ee7c1170726bd7f79d5a03c90d46c75115..6c16f1c849fc78f2dd70340994e6e45f407b2870 100644
--- a/chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc
+++ b/chrome/browser/chromeos/net/network_portal_detector_impl_browsertest.cc
@@ -5,12 +5,16 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
+#include "base/prefs/pref_service.h"
#include "base/run_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
+#include "chrome/browser/chromeos/net/captive_portal_ignore_proxy_policy_values.h"
#include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_utils.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_service_client.h"
@@ -141,6 +145,16 @@ class NetworkPortalDetectorImplBrowserTest
MessageCenter* message_center() { return MessageCenter::Get(); }
+ void SetIgnoreNoNetworkForTesting() {
+ network_portal_detector_->notification_controller_
+ .SetIgnoreNoNetworkForTesting();
+ }
+
+ const NetworkPortalWebDialog* GetDialog() const {
+ return network_portal_detector_->notification_controller_
+ .GetDialogForTesting();
+ }
+
private:
NetworkPortalDetectorImpl* network_portal_detector_;
@@ -203,4 +217,122 @@ IN_PROC_BROWSER_TEST_F(NetworkPortalDetectorImplBrowserTest,
action_checker.Expect(Controller::USER_ACTION_METRIC_CLOSED, 1)->Check());
}
+IN_PROC_BROWSER_TEST_F(NetworkPortalDetectorImplBrowserTest,
+ PRE_CaptivePortalAuthenticationIgnoresProxyTrue) {
+ RegisterUser(kTestUser);
+ StartupUtils::MarkOobeCompleted();
+ ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy()->Id());
+}
+
+IN_PROC_BROWSER_TEST_F(NetworkPortalDetectorImplBrowserTest,
+ CaptivePortalAuthenticationIgnoresProxyTrue) {
+ typedef NetworkPortalNotificationController Controller;
+
+ TestObserver observer;
+
+ EnumHistogramChecker ui_checker(kNotificationMetric,
+ Controller::NOTIFICATION_METRIC_COUNT, NULL);
ygorshenin1 2014/12/25 18:07:15 nit: you can use nullptr instead of NULL.
Alexander Alekseev 2015/01/05 20:53:02 Done.
+ EnumHistogramChecker action_checker(
+ kUserActionMetric, Controller::USER_ACTION_METRIC_COUNT, NULL);
+
+ LoginUser(kTestUser);
+ content::RunAllPendingInMessageLoop();
+
+ SetIgnoreNoNetworkForTesting();
+
+ ProfileManager::GetActiveUserProfile()->GetPrefs()->SetInteger(
+ prefs::kCaptivePortalAuthenticationIgnoresProxy,
+ CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_TRUE);
+
+ // User connects to wifi.
+ SetConnected(kWifiServicePath);
+
+ ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_SESSION, strategy()->Id());
+
+ // No notification until portal detection is completed.
+ ASSERT_FALSE(message_center()->FindVisibleNotificationById(kNotificationId));
+ RestartDetection();
+ CompleteURLFetch(net::OK, 200, NULL);
+
+ // Check that wifi is marked as behind the portal and that notification
+ // is displayed.
+ ASSERT_TRUE(message_center()->FindVisibleNotificationById(kNotificationId));
+ ASSERT_EQ(
+ NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL,
+ NetworkPortalDetector::Get()->GetCaptivePortalState(kWifiGuid).status);
+
+ // Wait until notification is displayed.
+ observer.WaitAndReset();
+
+ ASSERT_TRUE(
+ ui_checker.Expect(Controller::NOTIFICATION_METRIC_DISPLAYED, 1)->Check());
+ ASSERT_TRUE(action_checker.Check());
+
+ message_center()->ClickOnNotification(kNotificationId);
+
+ base::RunLoop().RunUntilIdle();
+
+ // Check that dialog is displayed.
+ ASSERT_TRUE(GetDialog());
+}
+
+IN_PROC_BROWSER_TEST_F(NetworkPortalDetectorImplBrowserTest,
+ PRE_CaptivePortalAuthenticationIgnoresProxyFalse) {
+ RegisterUser(kTestUser);
+ StartupUtils::MarkOobeCompleted();
+ ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy()->Id());
+}
+
+IN_PROC_BROWSER_TEST_F(NetworkPortalDetectorImplBrowserTest,
+ CaptivePortalAuthenticationIgnoresProxyFalse) {
ygorshenin1 2014/12/25 18:07:15 Both CaptivePortalAuthenticationIgnoresProxy{False
Alexander Alekseev 2015/01/05 20:53:02 Done.
+ typedef NetworkPortalNotificationController Controller;
+
+ TestObserver observer;
+
+ EnumHistogramChecker ui_checker(kNotificationMetric,
+ Controller::NOTIFICATION_METRIC_COUNT, NULL);
+ EnumHistogramChecker action_checker(
+ kUserActionMetric, Controller::USER_ACTION_METRIC_COUNT, NULL);
+
+ LoginUser(kTestUser);
+ content::RunAllPendingInMessageLoop();
+
+ SetIgnoreNoNetworkForTesting();
+
+ ProfileManager::GetActiveUserProfile()->GetPrefs()->SetInteger(
+ prefs::kCaptivePortalAuthenticationIgnoresProxy,
+ CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_FALSE);
+
+ // User connects to wifi.
+ SetConnected(kWifiServicePath);
+
+ ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_SESSION, strategy()->Id());
+
+ // No notification until portal detection is completed.
+ ASSERT_FALSE(message_center()->FindVisibleNotificationById(kNotificationId));
+ RestartDetection();
+ CompleteURLFetch(net::OK, 200, NULL);
+
+ // Check that wifi is marked as behind the portal and that notification
+ // is displayed.
+ ASSERT_TRUE(message_center()->FindVisibleNotificationById(kNotificationId));
+ ASSERT_EQ(
+ NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL,
+ NetworkPortalDetector::Get()->GetCaptivePortalState(kWifiGuid).status);
+
+ // Wait until notification is displayed.
+ observer.WaitAndReset();
+
+ ASSERT_TRUE(
+ ui_checker.Expect(Controller::NOTIFICATION_METRIC_DISPLAYED, 1)->Check());
+ ASSERT_TRUE(action_checker.Check());
+
+ message_center()->ClickOnNotification(kNotificationId);
+
+ base::RunLoop().RunUntilIdle();
+
+ // Check that dialog is not displayed.
+ ASSERT_FALSE(GetDialog());
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698