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/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "components/os_crypt/os_crypt_switches.h" | 18 #include "google_apis/gcm/base/fake_encryptor.h" |
19 #include "google_apis/gcm/base/mcs_message.h" | 19 #include "google_apis/gcm/base/mcs_message.h" |
20 #include "google_apis/gcm/base/mcs_util.h" | 20 #include "google_apis/gcm/base/mcs_util.h" |
21 #include "google_apis/gcm/protocol/mcs.pb.h" | 21 #include "google_apis/gcm/protocol/mcs.pb.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 namespace gcm { | 24 namespace gcm { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Number of persistent ids to use in tests. | 28 // Number of persistent ids to use in tests. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 : expected_success_(true), | 69 : expected_success_(true), |
70 next_persistent_id_(base::Time::Now().ToInternalValue()) { | 70 next_persistent_id_(base::Time::Now().ToInternalValue()) { |
71 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); | 71 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); |
72 run_loop_.reset(new base::RunLoop()); | 72 run_loop_.reset(new base::RunLoop()); |
73 } | 73 } |
74 | 74 |
75 GCMStoreImplTest::~GCMStoreImplTest() {} | 75 GCMStoreImplTest::~GCMStoreImplTest() {} |
76 | 76 |
77 void GCMStoreImplTest::SetUp() { | 77 void GCMStoreImplTest::SetUp() { |
78 testing::Test::SetUp(); | 78 testing::Test::SetUp(); |
79 #if defined(OS_MACOSX) | |
80 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
81 os_crypt::switches::kUseMockKeychain); | |
82 #endif // OS_MACOSX | |
83 } | 79 } |
84 | 80 |
85 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { | 81 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { |
86 return scoped_ptr<GCMStore>(new GCMStoreImpl( | 82 return scoped_ptr<GCMStore>(new GCMStoreImpl( |
87 temp_directory_.path(), | 83 temp_directory_.path(), |
88 message_loop_.message_loop_proxy())); | 84 message_loop_.message_loop_proxy(), |
| 85 make_scoped_ptr<Encryptor>(new FakeEncryptor))); |
89 } | 86 } |
90 | 87 |
91 std::string GCMStoreImplTest::GetNextPersistentId() { | 88 std::string GCMStoreImplTest::GetNextPersistentId() { |
92 return base::Uint64ToString(next_persistent_id_++); | 89 return base::Uint64ToString(next_persistent_id_++); |
93 } | 90 } |
94 | 91 |
95 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } | 92 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } |
96 | 93 |
97 void GCMStoreImplTest::LoadCallback( | 94 void GCMStoreImplTest::LoadCallback( |
98 scoped_ptr<GCMStore::LoadResult>* result_dst, | 95 scoped_ptr<GCMStore::LoadResult>* result_dst, |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 543 |
547 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 544 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
548 base::Unretained(this), | 545 base::Unretained(this), |
549 &load_result)); | 546 &load_result)); |
550 PumpLoop(); | 547 PumpLoop(); |
551 } | 548 } |
552 | 549 |
553 } // namespace | 550 } // namespace |
554 | 551 |
555 } // namespace gcm | 552 } // namespace gcm |
OLD | NEW |