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

Side by Side Diff: chrome/browser/chromeos/login/wizard_controller_browsertest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months 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
OLDNEW
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/wizard_controller.h" 5 #include "chrome/browser/chromeos/login/wizard_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 base::RunLoop* loop, 176 base::RunLoop* loop,
177 policy::AutoEnrollmentState actual_state) { 177 policy::AutoEnrollmentState actual_state) {
178 if (expected_state == actual_state) 178 if (expected_state == actual_state)
179 loop->Quit(); 179 loop->Quit();
180 } 180 }
181 181
182 void WaitForAutoEnrollmentState(policy::AutoEnrollmentState state) { 182 void WaitForAutoEnrollmentState(policy::AutoEnrollmentState state) {
183 base::RunLoop loop; 183 base::RunLoop loop;
184 AutoEnrollmentController* auto_enrollment_controller = 184 AutoEnrollmentController* auto_enrollment_controller =
185 LoginDisplayHost::default_host()->GetAutoEnrollmentController(); 185 LoginDisplayHost::default_host()->GetAutoEnrollmentController();
186 scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> 186 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
187 progress_subscription( 187 progress_subscription(
188 auto_enrollment_controller->RegisterProgressCallback( 188 auto_enrollment_controller->RegisterProgressCallback(
189 base::Bind(&QuitLoopOnAutoEnrollmentProgress, state, &loop))); 189 base::Bind(&QuitLoopOnAutoEnrollmentProgress, state, &loop)));
190 loop.Run(); 190 loop.Run();
191 } 191 }
192 192
193 } // namespace 193 } // namespace
194 194
195 using ::testing::_; 195 using ::testing::_;
196 196
(...skipping 14 matching lines...) Expand all
211 211
212 void RealShow() { 212 void RealShow() {
213 T::Show(); 213 T::Show();
214 } 214 }
215 215
216 void RealHide() { 216 void RealHide() {
217 T::Hide(); 217 T::Hide();
218 } 218 }
219 219
220 private: 220 private:
221 scoped_ptr<H> actor_; 221 std::unique_ptr<H> actor_;
222 }; 222 };
223 223
224 #define MOCK(mock_var, screen_name, mocked_class, actor_class) \ 224 #define MOCK(mock_var, screen_name, mocked_class, actor_class) \
225 mock_var = new MockOutShowHide<mocked_class, actor_class>( \ 225 mock_var = new MockOutShowHide<mocked_class, actor_class>( \
226 WizardController::default_controller(), new actor_class); \ 226 WizardController::default_controller(), new actor_class); \
227 WizardController::default_controller() \ 227 WizardController::default_controller() \
228 ->screens_[WizardController::screen_name] = make_linked_ptr(mock_var); \ 228 ->screens_[WizardController::screen_name] = make_linked_ptr(mock_var); \
229 EXPECT_CALL(*mock_var, Show()).Times(0); \ 229 EXPECT_CALL(*mock_var, Show()).Times(0); \
230 EXPECT_CALL(*mock_var, Hide()).Times(0); 230 EXPECT_CALL(*mock_var, Hide()).Times(0);
231 231
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // Check that output is unmuted now and at some level. 361 // Check that output is unmuted now and at some level.
362 CrasAudioHandler* cras = CrasAudioHandler::Get(); 362 CrasAudioHandler* cras = CrasAudioHandler::Get();
363 ASSERT_FALSE(cras->IsOutputMuted()); 363 ASSERT_FALSE(cras->IsOutputMuted());
364 ASSERT_EQ(WizardController::kMinAudibleOutputVolumePercent, 364 ASSERT_EQ(WizardController::kMinAudibleOutputVolumePercent,
365 cras->GetOutputVolumePercent()); 365 cras->GetOutputVolumePercent());
366 } 366 }
367 367
368 class WizardControllerTestURLFetcherFactory 368 class WizardControllerTestURLFetcherFactory
369 : public net::TestURLFetcherFactory { 369 : public net::TestURLFetcherFactory {
370 public: 370 public:
371 scoped_ptr<net::URLFetcher> CreateURLFetcher( 371 std::unique_ptr<net::URLFetcher> CreateURLFetcher(
372 int id, 372 int id,
373 const GURL& url, 373 const GURL& url,
374 net::URLFetcher::RequestType request_type, 374 net::URLFetcher::RequestType request_type,
375 net::URLFetcherDelegate* d) override { 375 net::URLFetcherDelegate* d) override {
376 if (base::StartsWith( 376 if (base::StartsWith(
377 url.spec(), 377 url.spec(),
378 SimpleGeolocationProvider::DefaultGeolocationProviderURL().spec(), 378 SimpleGeolocationProvider::DefaultGeolocationProviderURL().spec(),
379 base::CompareCase::SENSITIVE)) { 379 base::CompareCase::SENSITIVE)) {
380 return scoped_ptr<net::URLFetcher>(new net::FakeURLFetcher( 380 return std::unique_ptr<net::URLFetcher>(new net::FakeURLFetcher(
381 url, d, std::string(kGeolocationResponseBody), net::HTTP_OK, 381 url, d, std::string(kGeolocationResponseBody), net::HTTP_OK,
382 net::URLRequestStatus::SUCCESS)); 382 net::URLRequestStatus::SUCCESS));
383 } 383 }
384 if (base::StartsWith(url.spec(), 384 if (base::StartsWith(url.spec(),
385 chromeos::DefaultTimezoneProviderURL().spec(), 385 chromeos::DefaultTimezoneProviderURL().spec(),
386 base::CompareCase::SENSITIVE)) { 386 base::CompareCase::SENSITIVE)) {
387 return scoped_ptr<net::URLFetcher>(new net::FakeURLFetcher( 387 return std::unique_ptr<net::URLFetcher>(new net::FakeURLFetcher(
388 url, d, std::string(kTimezoneResponseBody), net::HTTP_OK, 388 url, d, std::string(kTimezoneResponseBody), net::HTTP_OK,
389 net::URLRequestStatus::SUCCESS)); 389 net::URLRequestStatus::SUCCESS));
390 } 390 }
391 return net::TestURLFetcherFactory::CreateURLFetcher( 391 return net::TestURLFetcherFactory::CreateURLFetcher(
392 id, url, request_type, d); 392 id, url, request_type, d);
393 } 393 }
394 ~WizardControllerTestURLFetcherFactory() override {} 394 ~WizardControllerTestURLFetcherFactory() override {}
395 }; 395 };
396 396
397 class TimeZoneTestRunner { 397 class TimeZoneTestRunner {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 void OnExit(BaseScreen& screen, BaseScreenDelegate::ExitCodes exit_code) { 500 void OnExit(BaseScreen& screen, BaseScreenDelegate::ExitCodes exit_code) {
501 WizardController::default_controller()->OnExit(screen, exit_code, 501 WizardController::default_controller()->OnExit(screen, exit_code,
502 nullptr /* context */); 502 nullptr /* context */);
503 } 503 }
504 504
505 chromeos::SimpleGeolocationProvider* GetGeolocationProvider() { 505 chromeos::SimpleGeolocationProvider* GetGeolocationProvider() {
506 return WizardController::default_controller()->geolocation_provider_.get(); 506 return WizardController::default_controller()->geolocation_provider_.get();
507 } 507 }
508 508
509 void WaitUntilTimezoneResolved() { 509 void WaitUntilTimezoneResolved() {
510 scoped_ptr<TimeZoneTestRunner> runner(new TimeZoneTestRunner); 510 std::unique_ptr<TimeZoneTestRunner> runner(new TimeZoneTestRunner);
511 if (!WizardController::default_controller() 511 if (!WizardController::default_controller()
512 ->SetOnTimeZoneResolvedForTesting( 512 ->SetOnTimeZoneResolvedForTesting(
513 base::Bind(&TimeZoneTestRunner::OnResolved, 513 base::Bind(&TimeZoneTestRunner::OnResolved,
514 base::Unretained(runner.get())))) 514 base::Unretained(runner.get()))))
515 return; 515 return;
516 516
517 runner->Run(); 517 runner->Run();
518 } 518 }
519 519
520 void ResetAutoEnrollmentCheckScreen() { 520 void ResetAutoEnrollmentCheckScreen() {
521 WizardController::default_controller()->screens_.erase( 521 WizardController::default_controller()->screens_.erase(
522 WizardController::kAutoEnrollmentCheckScreenName); 522 WizardController::kAutoEnrollmentCheckScreenName);
523 } 523 }
524 524
525 linked_ptr<MockNetworkScreen> mock_network_screen_; 525 linked_ptr<MockNetworkScreen> mock_network_screen_;
526 MockOutShowHide<MockUpdateScreen, MockUpdateView>* mock_update_screen_; 526 MockOutShowHide<MockUpdateScreen, MockUpdateView>* mock_update_screen_;
527 MockOutShowHide<MockEulaScreen, MockEulaView>* mock_eula_screen_; 527 MockOutShowHide<MockEulaScreen, MockEulaView>* mock_eula_screen_;
528 MockOutShowHide<MockEnrollmentScreen, 528 MockOutShowHide<MockEnrollmentScreen,
529 MockEnrollmentScreenActor>* mock_enrollment_screen_; 529 MockEnrollmentScreenActor>* mock_enrollment_screen_;
530 MockOutShowHide<MockAutoEnrollmentCheckScreen, 530 MockOutShowHide<MockAutoEnrollmentCheckScreen,
531 MockAutoEnrollmentCheckScreenActor>* mock_auto_enrollment_check_screen_; 531 MockAutoEnrollmentCheckScreenActor>* mock_auto_enrollment_check_screen_;
532 MockOutShowHide<MockWrongHWIDScreen, MockWrongHWIDScreenActor>* 532 MockOutShowHide<MockWrongHWIDScreen, MockWrongHWIDScreenActor>*
533 mock_wrong_hwid_screen_; 533 mock_wrong_hwid_screen_;
534 MockOutShowHide<MockEnableDebuggingScreen, 534 MockOutShowHide<MockEnableDebuggingScreen,
535 MockEnableDebuggingScreenActor>* mock_enable_debugging_screen_; 535 MockEnableDebuggingScreenActor>* mock_enable_debugging_screen_;
536 scoped_ptr<MockDeviceDisabledScreenActor> device_disabled_screen_actor_; 536 std::unique_ptr<MockDeviceDisabledScreenActor> device_disabled_screen_actor_;
537 537
538 private: 538 private:
539 NetworkPortalDetectorTestImpl* network_portal_detector_; 539 NetworkPortalDetectorTestImpl* network_portal_detector_;
540 540
541 // Use a test factory as a fallback so we don't have to deal with other 541 // Use a test factory as a fallback so we don't have to deal with other
542 // requests. 542 // requests.
543 scoped_ptr<WizardControllerTestURLFetcherFactory> fallback_fetcher_factory_; 543 std::unique_ptr<WizardControllerTestURLFetcherFactory>
544 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory_; 544 fallback_fetcher_factory_;
545 std::unique_ptr<net::FakeURLFetcherFactory> fetcher_factory_;
545 546
546 DISALLOW_COPY_AND_ASSIGN(WizardControllerFlowTest); 547 DISALLOW_COPY_AND_ASSIGN(WizardControllerFlowTest);
547 }; 548 };
548 549
549 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowMain) { 550 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowMain) {
550 CheckCurrentScreen(WizardController::kNetworkScreenName); 551 CheckCurrentScreen(WizardController::kNetworkScreenName);
551 552
552 WaitUntilJSIsReady(); 553 WaitUntilJSIsReady();
553 554
554 // Check visibility of the header bar. 555 // Check visibility of the header bar.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 : fake_session_manager_client_(NULL) { 897 : fake_session_manager_client_(NULL) {
897 } 898 }
898 899
899 ~WizardControllerBrokenLocalStateTest() override {} 900 ~WizardControllerBrokenLocalStateTest() override {}
900 901
901 void SetUpInProcessBrowserTestFixture() override { 902 void SetUpInProcessBrowserTestFixture() override {
902 WizardControllerTest::SetUpInProcessBrowserTestFixture(); 903 WizardControllerTest::SetUpInProcessBrowserTestFixture();
903 904
904 fake_session_manager_client_ = new FakeSessionManagerClient; 905 fake_session_manager_client_ = new FakeSessionManagerClient;
905 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( 906 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
906 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); 907 std::unique_ptr<SessionManagerClient>(fake_session_manager_client_));
907 } 908 }
908 909
909 void SetUpOnMainThread() override { 910 void SetUpOnMainThread() override {
910 PrefServiceFactory factory; 911 PrefServiceFactory factory;
911 factory.set_user_prefs(make_scoped_refptr(new PrefStoreStub())); 912 factory.set_user_prefs(make_scoped_refptr(new PrefStoreStub()));
912 local_state_ = factory.Create(new PrefRegistrySimple()); 913 local_state_ = factory.Create(new PrefRegistrySimple());
913 WizardController::set_local_state_for_testing(local_state_.get()); 914 WizardController::set_local_state_for_testing(local_state_.get());
914 915
915 WizardControllerTest::SetUpOnMainThread(); 916 WizardControllerTest::SetUpOnMainThread();
916 917
917 // Make sure that OOBE is run as an "official" build. 918 // Make sure that OOBE is run as an "official" build.
918 WizardController::default_controller()->is_official_build_ = true; 919 WizardController::default_controller()->is_official_build_ = true;
919 } 920 }
920 921
921 FakeSessionManagerClient* fake_session_manager_client() const { 922 FakeSessionManagerClient* fake_session_manager_client() const {
922 return fake_session_manager_client_; 923 return fake_session_manager_client_;
923 } 924 }
924 925
925 private: 926 private:
926 scoped_ptr<PrefService> local_state_; 927 std::unique_ptr<PrefService> local_state_;
927 FakeSessionManagerClient* fake_session_manager_client_; 928 FakeSessionManagerClient* fake_session_manager_client_;
928 929
929 DISALLOW_COPY_AND_ASSIGN(WizardControllerBrokenLocalStateTest); 930 DISALLOW_COPY_AND_ASSIGN(WizardControllerBrokenLocalStateTest);
930 }; 931 };
931 932
932 IN_PROC_BROWSER_TEST_F(WizardControllerBrokenLocalStateTest, 933 IN_PROC_BROWSER_TEST_F(WizardControllerBrokenLocalStateTest,
933 LocalStateCorrupted) { 934 LocalStateCorrupted) {
934 // Checks that after wizard controller initialization error screen 935 // Checks that after wizard controller initialization error screen
935 // in the proper state is displayed. 936 // in the proper state is displayed.
936 ASSERT_EQ(GetErrorScreen(), 937 ASSERT_EQ(GetErrorScreen(),
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 // TODO(merkulova): Add tests for bluetooth HID detection screen variations when 1221 // TODO(merkulova): Add tests for bluetooth HID detection screen variations when
1221 // UI and logic is ready. http://crbug.com/127016 1222 // UI and logic is ready. http://crbug.com/127016
1222 1223
1223 // TODO(dzhioev): Add tests for controller/host pairing flow. 1224 // TODO(dzhioev): Add tests for controller/host pairing flow.
1224 // http://crbug.com/375191 1225 // http://crbug.com/375191
1225 1226
1226 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 23, 1227 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 23,
1227 "tests for new control flow are missing"); 1228 "tests for new control flow are missing");
1228 1229
1229 } // namespace chromeos 1230 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.cc ('k') | chrome/browser/chromeos/mobile/mobile_activator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698