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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 #include "crypto/rsa_private_key.h" 90 #include "crypto/rsa_private_key.h"
91 #include "grit/chromium_strings.h" 91 #include "grit/chromium_strings.h"
92 #include "grit/generated_resources.h" 92 #include "grit/generated_resources.h"
93 #include "net/base/url_util.h" 93 #include "net/base/url_util.h"
94 #include "net/http/http_status_code.h" 94 #include "net/http/http_status_code.h"
95 #include "net/test/embedded_test_server/embedded_test_server.h" 95 #include "net/test/embedded_test_server/embedded_test_server.h"
96 #include "net/test/embedded_test_server/http_request.h" 96 #include "net/test/embedded_test_server/http_request.h"
97 #include "net/test/embedded_test_server/http_response.h" 97 #include "net/test/embedded_test_server/http_response.h"
98 #include "net/url_request/test_url_fetcher_factory.h" 98 #include "net/url_request/test_url_fetcher_factory.h"
99 #include "net/url_request/url_fetcher_delegate.h" 99 #include "net/url_request/url_fetcher_delegate.h"
100 #include "net/url_request/url_request_status.h"
100 #include "policy/policy_constants.h" 101 #include "policy/policy_constants.h"
101 #include "testing/gmock/include/gmock/gmock.h" 102 #include "testing/gmock/include/gmock/gmock.h"
102 #include "third_party/cros_system_api/dbus/service_constants.h" 103 #include "third_party/cros_system_api/dbus/service_constants.h"
103 #include "ui/base/l10n/l10n_util.h" 104 #include "ui/base/l10n/l10n_util.h"
104 #include "url/gurl.h" 105 #include "url/gurl.h"
105 106
106 namespace em = enterprise_management; 107 namespace em = enterprise_management;
107 108
108 using testing::InvokeWithoutArgs; 109 using testing::InvokeWithoutArgs;
109 using testing::Return; 110 using testing::Return;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return content::Details<const string16>(details)->find(UTF8ToUTF16(id)) != 250 return content::Details<const string16>(details)->find(UTF8ToUTF16(id)) !=
250 string16::npos; 251 string16::npos;
251 } 252 }
252 253
253 scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher( 254 scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher(
254 scoped_refptr<base::SequencedTaskRunner> task_runner, 255 scoped_refptr<base::SequencedTaskRunner> task_runner,
255 const base::Closure& callback, 256 const base::Closure& callback,
256 const GURL& url, 257 const GURL& url,
257 net::URLFetcherDelegate* delegate, 258 net::URLFetcherDelegate* delegate,
258 const std::string& response_data, 259 const std::string& response_data,
259 net::HttpStatusCode response_code) { 260 net::HttpStatusCode response_code,
261 net::URLRequestStatus::Status status) {
260 task_runner->PostTask(FROM_HERE, callback); 262 task_runner->PostTask(FROM_HERE, callback);
261 return make_scoped_ptr(new net::FakeURLFetcher( 263 return make_scoped_ptr(new net::FakeURLFetcher(
262 url, delegate, response_data, response_code)); 264 url, delegate, response_data, response_code, status));
263 } 265 }
264 266
265 } // namespace 267 } // namespace
266 268
267 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest { 269 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest {
268 protected: 270 protected:
269 DeviceLocalAccountTest() 271 DeviceLocalAccountTest()
270 : user_id_1_(GenerateDeviceLocalAccountUserId( 272 : user_id_1_(GenerateDeviceLocalAccountUserId(
271 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), 273 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)),
272 user_id_2_(GenerateDeviceLocalAccountUserId( 274 user_id_2_(GenerateDeviceLocalAccountUserId(
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 // Start serving external data at |kExternalDataURL|. 832 // Start serving external data at |kExternalDataURL|.
831 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop); 833 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop);
832 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory( 834 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory(
833 new net::FakeURLFetcherFactory( 835 new net::FakeURLFetcherFactory(
834 NULL, 836 NULL,
835 base::Bind(&RunCallbackAndReturnFakeURLFetcher, 837 base::Bind(&RunCallbackAndReturnFakeURLFetcher,
836 base::MessageLoopProxy::current(), 838 base::MessageLoopProxy::current(),
837 run_loop->QuitClosure()))); 839 run_loop->QuitClosure())));
838 fetcher_factory->SetFakeResponse(GURL(kExternalDataURL), 840 fetcher_factory->SetFakeResponse(GURL(kExternalDataURL),
839 kExternalData, 841 kExternalData,
840 net::HTTP_OK); 842 net::HTTP_OK,
843 net::URLRequestStatus::SUCCESS);
841 844
842 // TODO(bartfab): The test injects an ExternalDataFetcher for an arbitrary 845 // TODO(bartfab): The test injects an ExternalDataFetcher for an arbitrary
843 // policy. This is only done because there are no policies that reference 846 // policy. This is only done because there are no policies that reference
844 // external data yet. Once the first such policy is added, switch the test to 847 // external data yet. Once the first such policy is added, switch the test to
845 // that policy and stop injecting a manually instantiated ExternalDataFetcher. 848 // that policy and stop injecting a manually instantiated ExternalDataFetcher.
846 test::SetExternalDataReference(broker->core(), 849 test::SetExternalDataReference(broker->core(),
847 key::kHomepageLocation, 850 key::kHomepageLocation,
848 make_scoped_ptr(metadata->DeepCopy())); 851 make_scoped_ptr(metadata->DeepCopy()));
849 852
850 // The external data should be fetched and cached automatically. Wait for this 853 // The external data should be fetched and cached automatically. Wait for this
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (!IsSessionStarted()) { 1084 if (!IsSessionStarted()) {
1082 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, 1085 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
1083 base::Bind(IsSessionStarted)).Wait(); 1086 base::Bind(IsSessionStarted)).Wait();
1084 } 1087 }
1085 } 1088 }
1086 1089
1087 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, 1090 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance,
1088 TermsOfServiceTest, testing::Bool()); 1091 TermsOfServiceTest, testing::Bool());
1089 1092
1090 } // namespace policy 1093 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698