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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc

Issue 2496973002: arc: Partially migrate mojo types (Closed)
Patch Set: Fixed nit Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "components/user_manager/user_manager.h" 46 #include "components/user_manager/user_manager.h"
47 #include "content/public/browser/browser_thread.h" 47 #include "content/public/browser/browser_thread.h"
48 #include "net/base/upload_bytes_element_reader.h" 48 #include "net/base/upload_bytes_element_reader.h"
49 #include "net/base/upload_data_stream.h" 49 #include "net/base/upload_data_stream.h"
50 #include "net/url_request/url_request_test_job.h" 50 #include "net/url_request/url_request_test_job.h"
51 #include "testing/gtest/include/gtest/gtest.h" 51 #include "testing/gtest/include/gtest/gtest.h"
52 #include "url/gurl.h" 52 #include "url/gurl.h"
53 53
54 namespace { 54 namespace {
55 55
56 const char kRefreshToken[] = "fake-refresh-token"; 56 constexpr char kRefreshToken[] = "fake-refresh-token";
57 // Set managed auth token for Android managed accounts. 57 // Set managed auth token for Android managed accounts.
58 const char kManagedAuthToken[] = "managed-auth-token"; 58 constexpr char kManagedAuthToken[] = "managed-auth-token";
59 // Set unmanaged auth token for other Android unmanaged accounts. 59 // Set unmanaged auth token for other Android unmanaged accounts.
60 const char kUnmanagedAuthToken[] = "unmanaged-auth-token"; 60 constexpr char kUnmanagedAuthToken[] = "unmanaged-auth-token";
61 const char kWellKnownConsumerName[] = "test@gmail.com"; 61 constexpr char kWellKnownConsumerName[] = "test@gmail.com";
62 const char kFakeUserName[] = "test@example.com"; 62 constexpr char kFakeUserName[] = "test@example.com";
63 const char kFakeAuthCode[] = "fake-auth-code"; 63 constexpr char kFakeAuthCode[] = "fake-auth-code";
64 64
65 // JobCallback for the interceptor. 65 // JobCallback for the interceptor.
66 net::URLRequestJob* ResponseJob(net::URLRequest* request, 66 net::URLRequestJob* ResponseJob(net::URLRequest* request,
67 net::NetworkDelegate* network_delegate) { 67 net::NetworkDelegate* network_delegate) {
68 const net::UploadDataStream* upload = request->get_upload(); 68 const net::UploadDataStream* upload = request->get_upload();
69 if (!upload || !upload->GetElementReaders() || 69 if (!upload || !upload->GetElementReaders() ||
70 upload->GetElementReaders()->size() != 1 || 70 upload->GetElementReaders()->size() != 1 ||
71 !(*upload->GetElementReaders())[0]->AsBytesReader()) 71 !(*upload->GetElementReaders())[0]->AsBytesReader())
72 return nullptr; 72 return nullptr;
73 73
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; 342 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
343 343
344 DISALLOW_COPY_AND_ASSIGN(KioskArcAuthServiceTest); 344 DISALLOW_COPY_AND_ASSIGN(KioskArcAuthServiceTest);
345 }; 345 };
346 346
347 IN_PROC_BROWSER_TEST_F(KioskArcAuthServiceTest, RequestAccountInfoSuccess) { 347 IN_PROC_BROWSER_TEST_F(KioskArcAuthServiceTest, RequestAccountInfoSuccess) {
348 interceptor_->PushJobCallback(base::Bind(&ResponseJob)); 348 interceptor_->PushJobCallback(base::Bind(&ResponseJob));
349 349
350 auth_instance_.callback = 350 auth_instance_.callback =
351 base::Bind([](const mojom::AccountInfoPtr& account_info) { 351 base::Bind([](const mojom::AccountInfoPtr& account_info) {
352 EXPECT_EQ(kFakeAuthCode, account_info->auth_code); 352 EXPECT_EQ(kFakeAuthCode, account_info->auth_code.value());
353 EXPECT_EQ(mojom::ChromeAccountType::ROBOT_ACCOUNT, 353 EXPECT_EQ(mojom::ChromeAccountType::ROBOT_ACCOUNT,
354 account_info->account_type); 354 account_info->account_type);
355 EXPECT_FALSE(account_info->is_managed); 355 EXPECT_FALSE(account_info->is_managed);
356 }); 356 });
357 357
358 ArcAuthService::Get()->RequestAccountInfo(); 358 ArcAuthService::Get()->RequestAccountInfo();
359 base::RunLoop().RunUntilIdle(); 359 base::RunLoop().RunUntilIdle();
360 } 360 }
361 361
362 IN_PROC_BROWSER_TEST_F(KioskArcAuthServiceTest, RequestAccountInfoError) { 362 IN_PROC_BROWSER_TEST_F(KioskArcAuthServiceTest, RequestAccountInfoError) {
363 interceptor_->PushJobCallback( 363 interceptor_->PushJobCallback(
364 policy::TestRequestInterceptor::BadRequestJob()); 364 policy::TestRequestInterceptor::BadRequestJob());
365 365
366 auth_instance_.callback = 366 auth_instance_.callback =
367 base::Bind([](const mojom::AccountInfoPtr&) { FAIL(); }); 367 base::Bind([](const mojom::AccountInfoPtr&) { FAIL(); });
368 368
369 ArcAuthService::Get()->RequestAccountInfo(); 369 ArcAuthService::Get()->RequestAccountInfo();
370 // This MessageLoop will be stopped by AttemptUserExit(), that is called as 370 // This MessageLoop will be stopped by AttemptUserExit(), that is called as
371 // a result of error of auth code fetching. 371 // a result of error of auth code fetching.
372 base::RunLoop().Run(); 372 base::RunLoop().Run();
373 } 373 }
374 374
375 } // namespace arc 375 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698