OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/background_sync/background_sync_controller_impl.h" | 5 #include "chrome/browser/background_sync/background_sync_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/common/features.h" | 10 #include "chrome/common/features.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #endif | 21 #endif |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 using content::BackgroundSyncController; | 25 using content::BackgroundSyncController; |
26 | 26 |
27 const char kFieldTrialGroup[] = "GroupA"; | 27 const char kFieldTrialGroup[] = "GroupA"; |
28 | 28 |
29 class TestBackgroundSyncControllerImpl : public BackgroundSyncControllerImpl { | 29 class TestBackgroundSyncControllerImpl : public BackgroundSyncControllerImpl { |
30 public: | 30 public: |
31 TestBackgroundSyncControllerImpl(Profile* profile, | 31 TestBackgroundSyncControllerImpl( |
32 rappor::TestRapporService* rappor_service) | 32 Profile* profile, |
| 33 rappor::TestRapporServiceImpl* rappor_service) |
33 : BackgroundSyncControllerImpl(profile), | 34 : BackgroundSyncControllerImpl(profile), |
34 rappor_service_(rappor_service) {} | 35 rappor_service_(rappor_service) {} |
35 | 36 |
36 protected: | 37 protected: |
37 rappor::RapporService* GetRapporService() override { return rappor_service_; } | 38 rappor::RapporServiceImpl* GetRapporServiceImpl() override { |
| 39 return rappor_service_; |
| 40 } |
38 | 41 |
39 private: | 42 private: |
40 rappor::TestRapporService* rappor_service_; | 43 rappor::TestRapporServiceImpl* rappor_service_; |
41 | 44 |
42 DISALLOW_COPY_AND_ASSIGN(TestBackgroundSyncControllerImpl); | 45 DISALLOW_COPY_AND_ASSIGN(TestBackgroundSyncControllerImpl); |
43 }; | 46 }; |
44 | 47 |
45 class BackgroundSyncControllerImplTest : public testing::Test { | 48 class BackgroundSyncControllerImplTest : public testing::Test { |
46 protected: | 49 protected: |
47 BackgroundSyncControllerImplTest() | 50 BackgroundSyncControllerImplTest() |
48 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 51 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
49 controller_( | 52 controller_( |
50 new TestBackgroundSyncControllerImpl(&profile_, &rappor_service_)) { | 53 new TestBackgroundSyncControllerImpl(&profile_, &rappor_service_)) { |
51 ResetFieldTrialList(); | 54 ResetFieldTrialList(); |
52 #if BUILDFLAG(ANDROID_JAVA_UI) | 55 #if BUILDFLAG(ANDROID_JAVA_UI) |
53 BackgroundSyncLauncherAndroid::SetPlayServicesVersionCheckDisabledForTests( | 56 BackgroundSyncLauncherAndroid::SetPlayServicesVersionCheckDisabledForTests( |
54 true); | 57 true); |
55 #endif | 58 #endif |
56 } | 59 } |
57 | 60 |
58 void ResetFieldTrialList() { | 61 void ResetFieldTrialList() { |
59 field_trial_list_.reset( | 62 field_trial_list_.reset( |
60 new base::FieldTrialList(nullptr /* entropy provider */)); | 63 new base::FieldTrialList(nullptr /* entropy provider */)); |
61 variations::testing::ClearAllVariationParams(); | 64 variations::testing::ClearAllVariationParams(); |
62 base::FieldTrialList::CreateFieldTrial( | 65 base::FieldTrialList::CreateFieldTrial( |
63 BackgroundSyncControllerImpl::kFieldTrialName, kFieldTrialGroup); | 66 BackgroundSyncControllerImpl::kFieldTrialName, kFieldTrialGroup); |
64 } | 67 } |
65 | 68 |
66 content::TestBrowserThreadBundle thread_bundle_; | 69 content::TestBrowserThreadBundle thread_bundle_; |
67 TestingProfile profile_; | 70 TestingProfile profile_; |
68 rappor::TestRapporService rappor_service_; | 71 rappor::TestRapporServiceImpl rappor_service_; |
69 std::unique_ptr<TestBackgroundSyncControllerImpl> controller_; | 72 std::unique_ptr<TestBackgroundSyncControllerImpl> controller_; |
70 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 73 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
71 | 74 |
72 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncControllerImplTest); | 75 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncControllerImplTest); |
73 }; | 76 }; |
74 | 77 |
75 TEST_F(BackgroundSyncControllerImplTest, RapporTest) { | 78 TEST_F(BackgroundSyncControllerImplTest, RapporTest) { |
76 GURL url("http://www.example.com/foo/"); | 79 GURL url("http://www.example.com/foo/"); |
77 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 80 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
78 controller_->NotifyBackgroundSyncRegistered(url.GetOrigin()); | 81 controller_->NotifyBackgroundSyncRegistered(url.GetOrigin()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 sync_parameters.initial_retry_delay); | 157 sync_parameters.initial_retry_delay); |
155 EXPECT_EQ(200, sync_parameters.max_sync_attempts); | 158 EXPECT_EQ(200, sync_parameters.max_sync_attempts); |
156 EXPECT_EQ(300, sync_parameters.retry_delay_factor); | 159 EXPECT_EQ(300, sync_parameters.retry_delay_factor); |
157 EXPECT_EQ(base::TimeDelta::FromSeconds(400), | 160 EXPECT_EQ(base::TimeDelta::FromSeconds(400), |
158 sync_parameters.min_sync_recovery_time); | 161 sync_parameters.min_sync_recovery_time); |
159 EXPECT_EQ(base::TimeDelta::FromSeconds(500), | 162 EXPECT_EQ(base::TimeDelta::FromSeconds(500), |
160 sync_parameters.max_sync_event_duration); | 163 sync_parameters.max_sync_event_duration); |
161 } | 164 } |
162 | 165 |
163 } // namespace | 166 } // namespace |
OLD | NEW |