OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.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/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
14 #include "base/prefs/pref_registry_simple.h" | 14 #include "base/prefs/pref_registry_simple.h" |
15 #include "base/prefs/testing_pref_service.h" | 15 #include "base/prefs/testing_pref_service.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/test/test_simple_task_runner.h" | 18 #include "base/test/test_simple_task_runner.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "components/gcm_driver/fake_gcm_app_handler.h" | 20 #include "components/gcm_driver/fake_gcm_app_handler.h" |
21 #include "components/gcm_driver/fake_gcm_client.h" | 21 #include "components/gcm_driver/fake_gcm_client.h" |
22 #include "components/gcm_driver/fake_gcm_client_factory.h" | 22 #include "components/gcm_driver/fake_gcm_client_factory.h" |
23 #include "components/gcm_driver/gcm_app_handler.h" | 23 #include "components/gcm_driver/gcm_app_handler.h" |
24 #include "components/gcm_driver/gcm_channel_status_request.h" | 24 #include "components/gcm_driver/gcm_channel_status_request.h" |
25 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 25 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
26 #include "components/gcm_driver/gcm_client_factory.h" | 26 #include "components/gcm_driver/gcm_client_factory.h" |
27 #include "components/gcm_driver/gcm_connection_observer.h" | 27 #include "components/gcm_driver/gcm_connection_observer.h" |
28 #include "components/gcm_driver/proto/gcm_channel_status.pb.h" | |
29 #include "net/url_request/test_url_fetcher_factory.h" | 28 #include "net/url_request/test_url_fetcher_factory.h" |
30 #include "net/url_request/url_fetcher_delegate.h" | 29 #include "net/url_request/url_fetcher_delegate.h" |
31 #include "net/url_request/url_request_context_getter.h" | 30 #include "net/url_request/url_request_context_getter.h" |
32 #include "net/url_request/url_request_test_util.h" | 31 #include "net/url_request/url_request_test_util.h" |
| 32 #include "sync/protocol/experiment_status.pb.h" |
| 33 #include "sync/protocol/experiments_specifics.pb.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
34 | 35 |
35 namespace gcm { | 36 namespace gcm { |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 const char kTestAccountID1[] = "user1@example.com"; | 40 const char kTestAccountID1[] = "user1@example.com"; |
40 const char kTestAccountID2[] = "user2@example.com"; | 41 const char kTestAccountID2[] = "user2@example.com"; |
41 const char kTestAppID1[] = "TestApp1"; | 42 const char kTestAppID1[] = "TestApp1"; |
42 const char kTestAppID2[] = "TestApp2"; | 43 const char kTestAppID2[] = "TestApp2"; |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1014 |
1014 void GCMChannelStatusSyncerTest::SetUp() { | 1015 void GCMChannelStatusSyncerTest::SetUp() { |
1015 GCMDriverTest::SetUp(); | 1016 GCMDriverTest::SetUp(); |
1016 | 1017 |
1017 // Turn on all-user support. | 1018 // Turn on all-user support. |
1018 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("GCM", "Enabled")); | 1019 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("GCM", "Enabled")); |
1019 } | 1020 } |
1020 | 1021 |
1021 void GCMChannelStatusSyncerTest::CompleteGCMChannelStatusRequest( | 1022 void GCMChannelStatusSyncerTest::CompleteGCMChannelStatusRequest( |
1022 bool enabled, int poll_interval_seconds) { | 1023 bool enabled, int poll_interval_seconds) { |
1023 gcm_proto::ExperimentStatusResponse response_proto; | 1024 sync_pb::ExperimentStatusResponse response_proto; |
1024 response_proto.mutable_gcm_channel()->set_enabled(enabled); | 1025 sync_pb::ExperimentsSpecifics* experiment_specifics = |
| 1026 response_proto.add_experiment(); |
| 1027 experiment_specifics->mutable_gcm_channel()->set_enabled(enabled); |
1025 | 1028 |
1026 if (poll_interval_seconds) | 1029 if (poll_interval_seconds) |
1027 response_proto.set_poll_interval_seconds(poll_interval_seconds); | 1030 response_proto.set_poll_interval_seconds(poll_interval_seconds); |
1028 | 1031 |
1029 std::string response_string; | 1032 std::string response_string; |
1030 response_proto.SerializeToString(&response_string); | 1033 response_proto.SerializeToString(&response_string); |
1031 | 1034 |
1032 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 1035 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
1033 ASSERT_TRUE(fetcher); | 1036 ASSERT_TRUE(fetcher); |
1034 fetcher->set_response_code(net::HTTP_OK); | 1037 fetcher->set_response_code(net::HTTP_OK); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 // After start-up, the request should still be scheduled at the expected | 1222 // After start-up, the request should still be scheduled at the expected |
1220 // updated interval. | 1223 // updated interval. |
1221 actual_delay_seconds = | 1224 actual_delay_seconds = |
1222 syncer()->current_request_delay_interval().InSeconds(); | 1225 syncer()->current_request_delay_interval().InSeconds(); |
1223 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) | 1226 EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds)) |
1224 << "expected delay: " << expected_delay_seconds | 1227 << "expected delay: " << expected_delay_seconds |
1225 << " actual delay: " << actual_delay_seconds; | 1228 << " actual delay: " << actual_delay_seconds; |
1226 } | 1229 } |
1227 | 1230 |
1228 } // namespace gcm | 1231 } // namespace gcm |
OLD | NEW |