OLD | NEW |
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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
15 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 15 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
16 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth_code_fetcher.h" | 16 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth_code_fetcher.h" |
17 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 17 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
18 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 18 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
20 #include "chrome/browser/policy/cloud/test_request_interceptor.h" | 20 #include "chrome/browser/policy/cloud/test_request_interceptor.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chromeos/chromeos_switches.h" | 22 #include "components/arc/arc_util.h" |
23 #include "components/policy/core/common/cloud/device_management_service.h" | 23 #include "components/policy/core/common/cloud/device_management_service.h" |
24 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 24 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
25 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 25 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
26 #include "components/policy/core/common/policy_switches.h" | 26 #include "components/policy/core/common/policy_switches.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "net/base/upload_bytes_element_reader.h" | 28 #include "net/base/upload_bytes_element_reader.h" |
29 #include "net/base/upload_data_stream.h" | 29 #include "net/base/upload_data_stream.h" |
30 #include "net/url_request/url_request_test_job.h" | 30 #include "net/url_request/url_request_test_job.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
(...skipping 30 matching lines...) Expand all Loading... |
63 return new net::URLRequestTestJob(request, network_delegate, | 63 return new net::URLRequestTestJob(request, network_delegate, |
64 net::URLRequestTestJob::test_headers(), | 64 net::URLRequestTestJob::test_headers(), |
65 response_data, true); | 65 response_data, true); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 class ArcRobotAuthCodeFetcherBrowserTest : public InProcessBrowserTest { | 70 class ArcRobotAuthCodeFetcherBrowserTest : public InProcessBrowserTest { |
71 protected: | 71 protected: |
72 ArcRobotAuthCodeFetcherBrowserTest() = default; | 72 ArcRobotAuthCodeFetcherBrowserTest() = default; |
73 | |
74 // InProcessBrowserTest: | |
75 ~ArcRobotAuthCodeFetcherBrowserTest() override = default; | 73 ~ArcRobotAuthCodeFetcherBrowserTest() override = default; |
76 | 74 |
77 void SetUpCommandLine(base::CommandLine* command_line) override { | 75 void SetUpCommandLine(base::CommandLine* command_line) override { |
78 InProcessBrowserTest::SetUpCommandLine(command_line); | 76 InProcessBrowserTest::SetUpCommandLine(command_line); |
79 command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl, | 77 command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl, |
80 "http://localhost"); | 78 "http://localhost"); |
81 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 79 arc::SetArcAvailableCommandLineForTesting(command_line); |
82 } | 80 } |
83 | 81 |
84 void SetUpOnMainThread() override { | 82 void SetUpOnMainThread() override { |
85 interceptor_ = base::MakeUnique<policy::TestRequestInterceptor>( | 83 interceptor_ = base::MakeUnique<policy::TestRequestInterceptor>( |
86 "localhost", content::BrowserThread::GetTaskRunnerForThread( | 84 "localhost", content::BrowserThread::GetTaskRunnerForThread( |
87 content::BrowserThread::IO)); | 85 content::BrowserThread::IO)); |
88 | 86 |
89 user_manager_enabler_ = | 87 user_manager_enabler_ = |
90 base::MakeUnique<chromeos::ScopedUserManagerEnabler>( | 88 base::MakeUnique<chromeos::ScopedUserManagerEnabler>( |
91 new chromeos::FakeChromeUserManager()); | 89 new chromeos::FakeChromeUserManager()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // value. | 165 // value. |
168 std::string auth_code = "NOT-YET-FETCHED"; | 166 std::string auth_code = "NOT-YET-FETCHED"; |
169 auto robot_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>(); | 167 auto robot_fetcher = base::MakeUnique<ArcRobotAuthCodeFetcher>(); |
170 FetchAuthCode(robot_fetcher.get(), &auth_code); | 168 FetchAuthCode(robot_fetcher.get(), &auth_code); |
171 | 169 |
172 // Use EXPECT_EQ for better logging in case of failure. | 170 // Use EXPECT_EQ for better logging in case of failure. |
173 EXPECT_EQ(std::string(), auth_code); | 171 EXPECT_EQ(std::string(), auth_code); |
174 } | 172 } |
175 | 173 |
176 } // namespace arc | 174 } // namespace arc |
OLD | NEW |