| 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" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 gcm_store->Load(base::Bind( | 167 gcm_store->Load(base::Bind( |
| 168 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 168 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 169 PumpLoop(); | 169 PumpLoop(); |
| 170 | 170 |
| 171 ASSERT_TRUE(load_result.incoming_messages.empty()); | 171 ASSERT_TRUE(load_result.incoming_messages.empty()); |
| 172 ASSERT_TRUE(load_result.outgoing_messages.empty()); | 172 ASSERT_TRUE(load_result.outgoing_messages.empty()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Verify saving some outgoing messages, reopening the directory, and then | 175 // Verify saving some outgoing messages, reopening the directory, and then |
| 176 // removing those outgoing messages. | 176 // removing those outgoing messages. |
| 177 TEST_F(GCMStoreImplTest, OutgoingMessages) { | 177 // Fails on linux_asan crbug.com/337560 |
| 178 #if !defined(OS_POSIX) |
| 179 #define MAYBE_OutgoingMessages OutgoingMessages |
| 180 #else |
| 181 #define MAYBE_OutgoingMessages DISABLED_OutgoingMessages |
| 182 #endif |
| 183 TEST_F(GCMStoreImplTest, MAYBE_OutgoingMessages) { |
| 178 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); | 184 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); |
| 179 GCMStore::LoadResult load_result; | 185 GCMStore::LoadResult load_result; |
| 180 gcm_store->Load(base::Bind( | 186 gcm_store->Load(base::Bind( |
| 181 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 187 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 182 PumpLoop(); | 188 PumpLoop(); |
| 183 | 189 |
| 184 std::vector<std::string> persistent_ids; | 190 std::vector<std::string> persistent_ids; |
| 185 const int kNumPersistentIds = 10; | 191 const int kNumPersistentIds = 10; |
| 186 for (int i = 0; i < kNumPersistentIds; ++i) { | 192 for (int i = 0; i < kNumPersistentIds; ++i) { |
| 187 persistent_ids.push_back(GetNextPersistentId()); | 193 persistent_ids.push_back(GetNextPersistentId()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 load_result.outgoing_messages.clear(); | 227 load_result.outgoing_messages.clear(); |
| 222 gcm_store->Load(base::Bind( | 228 gcm_store->Load(base::Bind( |
| 223 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 229 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 224 PumpLoop(); | 230 PumpLoop(); |
| 225 | 231 |
| 226 ASSERT_TRUE(load_result.incoming_messages.empty()); | 232 ASSERT_TRUE(load_result.incoming_messages.empty()); |
| 227 ASSERT_TRUE(load_result.outgoing_messages.empty()); | 233 ASSERT_TRUE(load_result.outgoing_messages.empty()); |
| 228 } | 234 } |
| 229 | 235 |
| 230 // Verify incoming and outgoing messages don't conflict. | 236 // Verify incoming and outgoing messages don't conflict. |
| 231 TEST_F(GCMStoreImplTest, IncomingAndOutgoingMessages) { | 237 // Fails on linux_asan crbug.com/337560 |
| 238 #if !defined(OS_POSIX) |
| 239 #define MAYBE_IncomingAndOutgoingMessages IncomingAndOutgoingMessages |
| 240 #else |
| 241 #define MAYBE_IncomingAndOutgoingMessages DISABLED_IncomingAndOutgoingMessages |
| 242 #endif |
| 243 TEST_F(GCMStoreImplTest, MAYBE_IncomingAndOutgoingMessages) { |
| 232 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); | 244 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); |
| 233 GCMStore::LoadResult load_result; | 245 GCMStore::LoadResult load_result; |
| 234 gcm_store->Load(base::Bind( | 246 gcm_store->Load(base::Bind( |
| 235 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 247 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 236 PumpLoop(); | 248 PumpLoop(); |
| 237 | 249 |
| 238 std::vector<std::string> persistent_ids; | 250 std::vector<std::string> persistent_ids; |
| 239 const int kNumPersistentIds = 10; | 251 const int kNumPersistentIds = 10; |
| 240 for (int i = 0; i < kNumPersistentIds; ++i) { | 252 for (int i = 0; i < kNumPersistentIds; ++i) { |
| 241 persistent_ids.push_back(GetNextPersistentId()); | 253 persistent_ids.push_back(GetNextPersistentId()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 load_result.serial_number_mappings.user_serial_numbers[username1]); | 362 load_result.serial_number_mappings.user_serial_numbers[username1]); |
| 351 ASSERT_NE( | 363 ASSERT_NE( |
| 352 load_result.serial_number_mappings.user_serial_numbers.end(), | 364 load_result.serial_number_mappings.user_serial_numbers.end(), |
| 353 load_result.serial_number_mappings.user_serial_numbers.find(username2)); | 365 load_result.serial_number_mappings.user_serial_numbers.find(username2)); |
| 354 EXPECT_EQ(serial_number2, | 366 EXPECT_EQ(serial_number2, |
| 355 load_result.serial_number_mappings.user_serial_numbers[username2]); | 367 load_result.serial_number_mappings.user_serial_numbers[username2]); |
| 356 } | 368 } |
| 357 | 369 |
| 358 // Test that per-app message limits are enforced, persisted across restarts, | 370 // Test that per-app message limits are enforced, persisted across restarts, |
| 359 // and updated as messages are removed. | 371 // and updated as messages are removed. |
| 360 TEST_F(GCMStoreImplTest, PerAppMessageLimits) { | 372 // Fails on linux_asan crbug.com/337560 |
| 373 #if !defined(OS_POSIX) |
| 374 #define MAYBE_PerAppMessageLimits PerAppMessageLimits |
| 375 #else |
| 376 #define MAYBE_PerAppMessageLimits DISABLED_PerAppMessageLimits |
| 377 #endif |
| 378 TEST_F(GCMStoreImplTest, MAYBE_PerAppMessageLimits) { |
| 361 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); | 379 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); |
| 362 GCMStore::LoadResult load_result; | 380 GCMStore::LoadResult load_result; |
| 363 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 381 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
| 364 base::Unretained(this), | 382 base::Unretained(this), |
| 365 &load_result)); | 383 &load_result)); |
| 366 | 384 |
| 367 // Add the initial (below app limit) messages. | 385 // Add the initial (below app limit) messages. |
| 368 for (int i = 0; i < kNumMessagesPerApp; ++i) { | 386 for (int i = 0; i < kNumMessagesPerApp; ++i) { |
| 369 mcs_proto::DataMessageStanza message; | 387 mcs_proto::DataMessageStanza message; |
| 370 message.set_from(kAppName); | 388 message.set_from(kAppName); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 MCSMessage(message), | 476 MCSMessage(message), |
| 459 base::Bind(&GCMStoreImplTest::UpdateCallback, | 477 base::Bind(&GCMStoreImplTest::UpdateCallback, |
| 460 base::Unretained(this)))); | 478 base::Unretained(this)))); |
| 461 PumpLoop(); | 479 PumpLoop(); |
| 462 } | 480 } |
| 463 } | 481 } |
| 464 | 482 |
| 465 } // namespace | 483 } // namespace |
| 466 | 484 |
| 467 } // namespace gcm | 485 } // namespace gcm |
| OLD | NEW |