OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/policy/core/common/cloud/external_policy_data_fetcher.h" | 5 #include "components/policy/core/common/cloud/external_policy_data_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 const int64 kExternalPolicyDataMaxSize = 5 * 1024 * 1024; // 5 MB. | 29 const int64 kExternalPolicyDataMaxSize = 5 * 1024 * 1024; // 5 MB. |
30 | 30 |
31 const char* kExternalPolicyDataPayload = "External policy data"; | 31 const char* kExternalPolicyDataPayload = "External policy data"; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 class ExternalPolicyDataFetcherTest : public testing::Test { | 35 class ExternalPolicyDataFetcherTest : public testing::Test { |
36 protected: | 36 protected: |
37 ExternalPolicyDataFetcherTest(); | 37 ExternalPolicyDataFetcherTest(); |
38 virtual ~ExternalPolicyDataFetcherTest(); | 38 ~ExternalPolicyDataFetcherTest() override; |
39 | 39 |
40 // testing::Test: | 40 // testing::Test: |
41 virtual void SetUp() override; | 41 void SetUp() override; |
42 | 42 |
43 void StartJob(int index); | 43 void StartJob(int index); |
44 void CancelJob(int index); | 44 void CancelJob(int index); |
45 | 45 |
46 void OnJobFinished(int job_index, | 46 void OnJobFinished(int job_index, |
47 ExternalPolicyDataFetcher::Result result, | 47 ExternalPolicyDataFetcher::Result result, |
48 scoped_ptr<std::string> data); | 48 scoped_ptr<std::string> data); |
49 int GetAndResetCallbackCount(); | 49 int GetAndResetCallbackCount(); |
50 | 50 |
51 net::TestURLFetcherFactory fetcher_factory_; | 51 net::TestURLFetcherFactory fetcher_factory_; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 // Verify that the callback is invoked with the retrieved data. | 487 // Verify that the callback is invoked with the retrieved data. |
488 owner_task_runner_->RunUntilIdle(); | 488 owner_task_runner_->RunUntilIdle(); |
489 EXPECT_EQ(1, GetAndResetCallbackCount()); | 489 EXPECT_EQ(1, GetAndResetCallbackCount()); |
490 EXPECT_EQ(1, callback_job_index_); | 490 EXPECT_EQ(1, callback_job_index_); |
491 EXPECT_EQ(ExternalPolicyDataFetcher::SUCCESS, callback_result_); | 491 EXPECT_EQ(ExternalPolicyDataFetcher::SUCCESS, callback_result_); |
492 ASSERT_TRUE(callback_data_); | 492 ASSERT_TRUE(callback_data_); |
493 EXPECT_EQ(kExternalPolicyDataPayload, *callback_data_); | 493 EXPECT_EQ(kExternalPolicyDataPayload, *callback_data_); |
494 } | 494 } |
495 | 495 |
496 } // namespace policy | 496 } // namespace policy |
OLD | NEW |