Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / captive_portal_window_browsertest.cc
index e0e5247..cccf9ae 100644 (file)
@@ -8,7 +8,12 @@
 #include "base/memory/scoped_ptr.h"
 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h"
 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
+#include "chrome/browser/chromeos/login/login_manager_test.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
+#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
 #include "chrome/browser/chromeos/login/webui_login_view.h"
+#include "chrome/browser/chromeos/net/network_portal_detector.h"
+#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chromeos/chromeos_switches.h"
 
@@ -16,6 +21,8 @@ namespace chromeos {
 
 namespace {
 
+const char kStubEthernetServicePath[] = "eth1";
+
 // Stub implementation of CaptivePortalWindowProxyDelegate, does
 // nothing and used to instantiate CaptivePortalWindowProxy.
 class CaptivePortalWindowProxyStubDelegate
@@ -167,4 +174,53 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, MultipleCalls) {
   CheckState(false, 2);
 }
 
+class CaptivePortalWindowCtorDtorTest : public LoginManagerTest {
+ public:
+  CaptivePortalWindowCtorDtorTest()
+      : LoginManagerTest(false) {}
+  virtual ~CaptivePortalWindowCtorDtorTest() {}
+
+  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+    LoginManagerTest::SetUpInProcessBrowserTestFixture();
+
+    network_portal_detector_ = new NetworkPortalDetectorTestImpl();
+    NetworkPortalDetector::InitializeForTesting(network_portal_detector_);
+    NetworkPortalDetector::CaptivePortalState portal_state;
+    portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL;
+    portal_state.response_code = 200;
+    network_portal_detector_->SetDefaultNetworkPathForTesting(
+        kStubEthernetServicePath);
+    network_portal_detector_->SetDetectionResultsForTesting(
+        kStubEthernetServicePath, portal_state);
+  }
+
+ protected:
+  NetworkPortalDetectorTestImpl* network_portal_detector() {
+    return network_portal_detector_;
+  }
+
+ private:
+  NetworkPortalDetectorTestImpl* network_portal_detector_;
+
+  DISALLOW_COPY_AND_ASSIGN(CaptivePortalWindowCtorDtorTest);
+};
+
+IN_PROC_BROWSER_TEST_F(CaptivePortalWindowCtorDtorTest, PRE_OpenPortalDialog) {
+  StartupUtils::MarkOobeCompleted();
+}
+
+IN_PROC_BROWSER_TEST_F(CaptivePortalWindowCtorDtorTest, OpenPortalDialog) {
+  network_portal_detector()->NotifyObserversForTesting();
+  OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait();
+  LoginDisplayHostImpl* host =
+      static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host());
+
+  ASSERT_TRUE(host);
+  OobeUI* oobe = host->GetOobeUI();
+  ASSERT_TRUE(oobe);
+  ErrorScreenActor* actor = oobe->GetErrorScreenActor();
+  ASSERT_TRUE(actor);
+  actor->ShowCaptivePortal();
+}
+
 }  // namespace chromeos