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

Side by Side Diff: chrome/browser/ui/desktop_ios_promotion/sms_service_unittest.cc

Issue 2797293002: Use ScopedTaskEnvironment instead of MessageLoop in chrome unit tests. (Closed)
Patch Set: Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/ui/desktop_ios_promotion/sms_service.h" 5 #include "chrome/browser/ui/desktop_ios_promotion/sms_service.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/scoped_task_environment.h"
8 #include "components/signin/core/browser/account_tracker_service.h" 9 #include "components/signin/core/browser/account_tracker_service.h"
9 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" 10 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
10 #include "components/signin/core/browser/fake_signin_manager.h" 11 #include "components/signin/core/browser/fake_signin_manager.h"
11 #include "components/signin/core/browser/test_signin_client.h" 12 #include "components/signin/core/browser/test_signin_client.h"
12 #include "net/http/http_status_code.h" 13 #include "net/http/http_status_code.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace { 17 namespace {
17 18
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 TestingSMSService* sms_service() { return &sms_service_; } 141 TestingSMSService* sms_service() { return &sms_service_; }
141 142
142 void SetNextRequestResponseData(int response_code, 143 void SetNextRequestResponseData(int response_code,
143 const std::string& response_body) { 144 const std::string& response_body) {
144 sms_service_.SetNextRequestResponseData(response_code, response_body); 145 sms_service_.SetNextRequestResponseData(response_code, response_body);
145 } 146 }
146 147
147 private: 148 private:
148 base::MessageLoop message_loop_; 149 base::test::ScopedTaskEnvironment scoped_task_environment_;
149 FakeProfileOAuth2TokenService token_service_; 150 FakeProfileOAuth2TokenService token_service_;
150 AccountTrackerService account_tracker_; 151 AccountTrackerService account_tracker_;
151 TestSigninClient signin_client_; 152 TestSigninClient signin_client_;
152 FakeSigninManagerBase signin_manager_; 153 FakeSigninManagerBase signin_manager_;
153 scoped_refptr<net::URLRequestContextGetter> url_request_context_; 154 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
154 TestingSMSService sms_service_; 155 TestingSMSService sms_service_;
155 156
156 DISALLOW_COPY_AND_ASSIGN(SMSServiceTest); 157 DISALLOW_COPY_AND_ASSIGN(SMSServiceTest);
157 }; 158 };
158 159
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 base::Bind(&TestingSMSService::QueryPhoneNumberCallbackFailed, 191 base::Bind(&TestingSMSService::QueryPhoneNumberCallbackFailed,
191 base::Unretained(sms_service()))); 192 base::Unretained(sms_service())));
192 base::RunLoop().RunUntilIdle(); 193 base::RunLoop().RunUntilIdle();
193 std::string send_sms_invalid = "{}"; 194 std::string send_sms_invalid = "{}";
194 sms_service()->SetNextRequestResponseData(net::HTTP_OK, send_sms_invalid); 195 sms_service()->SetNextRequestResponseData(net::HTTP_OK, send_sms_invalid);
195 sms_service()->SendSMS( 196 sms_service()->SendSMS(
196 promo_id, base::Bind(&TestingSMSService::QueryPhoneNumberCallbackFailed, 197 promo_id, base::Bind(&TestingSMSService::QueryPhoneNumberCallbackFailed,
197 base::Unretained(sms_service()))); 198 base::Unretained(sms_service())));
198 base::RunLoop().RunUntilIdle(); 199 base::RunLoop().RunUntilIdle();
199 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698