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 "google_apis/gcm/base/fake_encryptor.h" | 18 #include "components/os_crypt/os_crypt_switches.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 |
79 } | 83 } |
80 | 84 |
81 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { | 85 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { |
82 return scoped_ptr<GCMStore>(new GCMStoreImpl( | 86 return scoped_ptr<GCMStore>(new GCMStoreImpl( |
83 temp_directory_.path(), | 87 temp_directory_.path(), |
84 message_loop_.message_loop_proxy(), | 88 message_loop_.message_loop_proxy())); |
85 make_scoped_ptr<Encryptor>(new FakeEncryptor))); | |
86 } | 89 } |
87 | 90 |
88 std::string GCMStoreImplTest::GetNextPersistentId() { | 91 std::string GCMStoreImplTest::GetNextPersistentId() { |
89 return base::Uint64ToString(next_persistent_id_++); | 92 return base::Uint64ToString(next_persistent_id_++); |
90 } | 93 } |
91 | 94 |
92 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } | 95 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } |
93 | 96 |
94 void GCMStoreImplTest::LoadCallback( | 97 void GCMStoreImplTest::LoadCallback( |
95 scoped_ptr<GCMStore::LoadResult>* result_dst, | 98 scoped_ptr<GCMStore::LoadResult>* result_dst, |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 546 |
544 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 547 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
545 base::Unretained(this), | 548 base::Unretained(this), |
546 &load_result)); | 549 &load_result)); |
547 PumpLoop(); | 550 PumpLoop(); |
548 } | 551 } |
549 | 552 |
550 } // namespace | 553 } // namespace |
551 | 554 |
552 } // namespace gcm | 555 } // namespace gcm |
OLD | NEW |