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 "google_apis/gcm/engine/gcm_store_impl.h" | 5 #include "google_apis/gcm/engine/gcm_store_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "google_apis/gcm/base/mcs_message.h" | 17 #include "google_apis/gcm/base/mcs_message.h" |
18 #include "google_apis/gcm/base/mcs_util.h" | 18 #include "google_apis/gcm/base/mcs_util.h" |
19 #include "google_apis/gcm/engine/gcm_internals_builder.h" | |
19 #include "google_apis/gcm/protocol/mcs.pb.h" | 20 #include "google_apis/gcm/protocol/mcs.pb.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace gcm { | 23 namespace gcm { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Number of persistent ids to use in tests. | 27 // Number of persistent ids to use in tests. |
27 const int kNumPersistentIds = 10; | 28 const int kNumPersistentIds = 10; |
28 | 29 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 GCMStoreImplTest::GCMStoreImplTest() | 65 GCMStoreImplTest::GCMStoreImplTest() |
65 : expected_success_(true), | 66 : expected_success_(true), |
66 next_persistent_id_(base::Time::Now().ToInternalValue()) { | 67 next_persistent_id_(base::Time::Now().ToInternalValue()) { |
67 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); | 68 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); |
68 run_loop_.reset(new base::RunLoop()); | 69 run_loop_.reset(new base::RunLoop()); |
69 } | 70 } |
70 | 71 |
71 GCMStoreImplTest::~GCMStoreImplTest() {} | 72 GCMStoreImplTest::~GCMStoreImplTest() {} |
72 | 73 |
73 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { | 74 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { |
74 return scoped_ptr<GCMStore>(new GCMStoreImpl( | 75 GCMInternalsBuilder builder; |
75 true, | 76 builder.SetUpForTesting(); |
76 temp_directory_.path(), | 77 return builder.BuildGCMStore(temp_directory_.path(), |
77 message_loop_.message_loop_proxy())); | 78 message_loop_.message_loop_proxy()).Pass(); |
jianli
2014/04/09 23:36:58
No need to call Pass.
| |
78 } | 79 } |
79 | 80 |
80 std::string GCMStoreImplTest::GetNextPersistentId() { | 81 std::string GCMStoreImplTest::GetNextPersistentId() { |
81 return base::Uint64ToString(next_persistent_id_++); | 82 return base::Uint64ToString(next_persistent_id_++); |
82 } | 83 } |
83 | 84 |
84 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } | 85 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } |
85 | 86 |
86 void GCMStoreImplTest::LoadCallback( | 87 void GCMStoreImplTest::LoadCallback( |
87 scoped_ptr<GCMStore::LoadResult>* result_dst, | 88 scoped_ptr<GCMStore::LoadResult>* result_dst, |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 | 488 |
488 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 489 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
489 base::Unretained(this), | 490 base::Unretained(this), |
490 &load_result)); | 491 &load_result)); |
491 PumpLoop(); | 492 PumpLoop(); |
492 } | 493 } |
493 | 494 |
494 } // namespace | 495 } // namespace |
495 | 496 |
496 } // namespace gcm | 497 } // namespace gcm |
OLD | NEW |