| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/screens/network_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/network_screen.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" | 11 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" |
| 12 #include "chrome/browser/chromeos/login/helper.h" | 12 #include "chrome/browser/chromeos/login/helper.h" |
| 13 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 13 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 14 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" | 14 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" |
| 15 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 15 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 16 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" | 16 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 18 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 19 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
| 20 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
| 21 #include "chromeos/dbus/fake_session_manager_client.h" | 21 #include "chromeos/dbus/fake_session_manager_client.h" |
| 22 #include "chromeos/dbus/shill_manager_client.h" |
| 22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
| 23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "third_party/cros_system_api/dbus/service_constants.h" | 27 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 27 #include "ui/views/controls/button/button.h" | 28 #include "ui/views/controls/button/button.h" |
| 28 | 29 |
| 29 using ::testing::_; | 30 using ::testing::_; |
| 30 using ::testing::AnyNumber; | 31 using ::testing::AnyNumber; |
| 31 using ::testing::Return; | 32 using ::testing::Return; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // Close infobubble with error message - it makes the test stable. | 152 // Close infobubble with error message - it makes the test stable. |
| 152 // EXPECT_FALSE(actor_->IsContinueEnabled()); | 153 // EXPECT_FALSE(actor_->IsContinueEnabled()); |
| 153 // EXPECT_FALSE(actor_->IsConnecting()); | 154 // EXPECT_FALSE(actor_->IsConnecting()); |
| 154 // actor_->ClearErrors(); | 155 // actor_->ClearErrors(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 class HandsOffNetworkScreenTest : public NetworkScreenTest { | 158 class HandsOffNetworkScreenTest : public NetworkScreenTest { |
| 158 public: | 159 public: |
| 159 HandsOffNetworkScreenTest() {} | 160 HandsOffNetworkScreenTest() {} |
| 160 | 161 |
| 162 protected: |
| 163 void SetUpOnMainThread() override { |
| 164 NetworkScreenTest::SetUpOnMainThread(); |
| 165 |
| 166 // Set up fake networks. |
| 167 DBusThreadManager::Get() |
| 168 ->GetShillManagerClient() |
| 169 ->GetTestInterface() |
| 170 ->SetupDefaultEnvironment(); |
| 171 } |
| 172 |
| 161 private: | 173 private: |
| 162 // Overridden from InProcessBrowserTest: | 174 // Overridden from InProcessBrowserTest: |
| 163 void SetUpCommandLine(base::CommandLine* command_line) override { | 175 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 164 command_line->AppendSwitchASCII( | 176 command_line->AppendSwitchASCII( |
| 165 switches::kEnterpriseEnableZeroTouchEnrollment, "hands-off"); | 177 switches::kEnterpriseEnableZeroTouchEnrollment, "hands-off"); |
| 166 } | 178 } |
| 167 | 179 |
| 168 DISALLOW_COPY_AND_ASSIGN(HandsOffNetworkScreenTest); | 180 DISALLOW_COPY_AND_ASSIGN(HandsOffNetworkScreenTest); |
| 169 }; | 181 }; |
| 170 | 182 |
| 171 #if defined(OS_CHROMEOS) | 183 IN_PROC_BROWSER_TEST_F(HandsOffNetworkScreenTest, RequiresNoInput) { |
| 172 #define MAYBE_RequiresNoInput DISABLED_RequiresNoInput | |
| 173 #else | |
| 174 #define MAYBE_RequiresNoInput RequiresNoInput | |
| 175 #endif | |
| 176 | |
| 177 IN_PROC_BROWSER_TEST_F(HandsOffNetworkScreenTest, MAYBE_RequiresNoInput) { | |
| 178 WizardController* wizard_controller = WizardController::default_controller(); | 184 WizardController* wizard_controller = WizardController::default_controller(); |
| 179 | 185 |
| 180 // Allow the WizardController to advance throught the enrollment flow. | 186 // Allow the WizardController to advance throught the enrollment flow. |
| 181 network_screen_->base_screen_delegate_ = wizard_controller; | 187 network_screen_->base_screen_delegate_ = wizard_controller; |
| 182 | 188 |
| 183 // Simulate a network connection. | 189 // Simulate a network connection. |
| 184 EXPECT_CALL(*mock_network_state_helper_, IsConnected()) | 190 EXPECT_CALL(*mock_network_state_helper_, IsConnected()) |
| 191 .Times(AnyNumber()) |
| 185 .WillRepeatedly((Return(true))); | 192 .WillRepeatedly((Return(true))); |
| 186 network_screen_->UpdateStatus(); | 193 network_screen_->UpdateStatus(); |
| 187 | 194 |
| 188 // Check if NetworkScreen::OnContinueButtonPressed() is called | 195 // Check if NetworkScreen::OnContinueButtonPressed() is called |
| 189 // Note that checking network_screen_->continue_pressed_ is not | 196 // Note that checking network_screen_->continue_pressed_ is not |
| 190 // sufficient since there are cases where OnContinueButtonPressed() | 197 // sufficient since there are cases where OnContinueButtonPressed() |
| 191 // is called but where this variable is not set to true. | 198 // is called but where this variable is not set to true. |
| 192 ASSERT_TRUE((!network_screen_->is_network_subscribed_) && | 199 ASSERT_TRUE((!network_screen_->is_network_subscribed_) && |
| 193 network_screen_->network_state_helper_->IsConnected()); | 200 network_screen_->network_state_helper_->IsConnected()); |
| 194 | 201 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 218 "}" | 225 "}" |
| 219 "SendReplyIfEnrollmentDone();", | 226 "SendReplyIfEnrollmentDone();", |
| 220 &done)); | 227 &done)); |
| 221 | 228 |
| 222 // Reset the enrollment helper so there is no side effect with other tests. | 229 // Reset the enrollment helper so there is no side effect with other tests. |
| 223 static_cast<EnrollmentScreen*>(wizard_controller->current_screen()) | 230 static_cast<EnrollmentScreen*>(wizard_controller->current_screen()) |
| 224 ->enrollment_helper_.reset(); | 231 ->enrollment_helper_.reset(); |
| 225 } | 232 } |
| 226 | 233 |
| 227 } // namespace chromeos | 234 } // namespace chromeos |
| OLD | NEW |