OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // | |
5 | 4 |
6 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 5 #include "chrome/browser/invalidation/invalidator_storage.h" |
7 | 6 |
8 #include "base/bind.h" | 7 #include "base/bind.h" |
9 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
11 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
13 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
14 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_pref_service_syncable.h" | 14 #include "chrome/test/base/testing_pref_service_syncable.h" |
16 #include "sync/internal_api/public/base/invalidation_test_util.h" | 15 #include "sync/internal_api/public/base/invalidation_test_util.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 using syncer::InvalidationStateMap; | 19 using syncer::InvalidationStateMap; |
21 | 20 |
22 namespace browser_sync { | |
23 | |
24 namespace { | 21 namespace { |
25 | 22 |
26 const char kSourceKey[] = "source"; | 23 const char kSourceKey[] = "source"; |
27 const char kNameKey[] = "name"; | 24 const char kNameKey[] = "name"; |
28 const char kMaxVersionKey[] = "max-version"; | 25 const char kMaxVersionKey[] = "max-version"; |
29 const char kPayloadKey[] = "payload"; | 26 const char kPayloadKey[] = "payload"; |
30 const char kCurrentAckHandleKey[] = "current-ack"; | 27 const char kCurrentAckHandleKey[] = "current-ack"; |
31 const char kExpectedAckHandleKey[] = "expected-ack"; | 28 const char kExpectedAckHandleKey[] = "expected-ack"; |
32 | 29 |
33 const int kChromeSyncSourceId = 1004; | 30 const int kChromeSyncSourceId = 1004; |
34 | 31 |
35 void GenerateAckHandlesTestHelper(syncer::AckHandleMap* output, | 32 void GenerateAckHandlesTestHelper(syncer::AckHandleMap* output, |
36 const syncer::AckHandleMap& input) { | 33 const syncer::AckHandleMap& input) { |
37 *output = input; | 34 *output = input; |
38 } | 35 } |
39 | 36 |
40 } // namespace | 37 } // namespace |
41 | 38 |
| 39 namespace invalidation { |
| 40 |
42 class InvalidatorStorageTest : public testing::Test { | 41 class InvalidatorStorageTest : public testing::Test { |
43 public: | 42 public: |
44 InvalidatorStorageTest() | 43 InvalidatorStorageTest() |
45 : kBookmarksId_(kChromeSyncSourceId, "BOOKMARK"), | 44 : kBookmarksId_(kChromeSyncSourceId, "BOOKMARK"), |
46 kPreferencesId_(kChromeSyncSourceId, "PREFERENCE"), | 45 kPreferencesId_(kChromeSyncSourceId, "PREFERENCE"), |
47 kAppNotificationsId_(kChromeSyncSourceId, "APP_NOTIFICATION"), | 46 kAppNotificationsId_(kChromeSyncSourceId, "APP_NOTIFICATION"), |
48 kAutofillId_(kChromeSyncSourceId, "AUTOFILL") {} | 47 kAutofillId_(kChromeSyncSourceId, "AUTOFILL") {} |
49 | 48 |
50 virtual void SetUp() { | 49 virtual void SetUp() { |
51 InvalidatorStorage::RegisterUserPrefs(pref_service_.registry()); | 50 InvalidatorStorage::RegisterUserPrefs(pref_service_.registry()); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 ASSERT_TRUE(ack_handle_map.end() != it); | 496 ASSERT_TRUE(ack_handle_map.end() != it); |
498 EXPECT_TRUE(it->second.IsValid()); | 497 EXPECT_TRUE(it->second.IsValid()); |
499 state_map[kBookmarksId_].expected = it->second; | 498 state_map[kBookmarksId_].expected = it->second; |
500 EXPECT_EQ(state_map, storage.GetAllInvalidationStates()); | 499 EXPECT_EQ(state_map, storage.GetAllInvalidationStates()); |
501 | 500 |
502 storage.Acknowledge(kBookmarksId_, it->second); | 501 storage.Acknowledge(kBookmarksId_, it->second); |
503 state_map[kBookmarksId_].current = it->second; | 502 state_map[kBookmarksId_].current = it->second; |
504 EXPECT_EQ(state_map, storage.GetAllInvalidationStates()); | 503 EXPECT_EQ(state_map, storage.GetAllInvalidationStates()); |
505 } | 504 } |
506 | 505 |
507 } // namespace browser_sync | 506 } // namespace invalidation |
OLD | NEW |