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 #ifndef SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ | 5 #ifndef SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ |
6 #define SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ | 6 #define SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ |
7 | 7 |
8 #include "sync/test/mock_invalidation.h" | 8 #include "sync/test/mock_invalidation.h" |
9 | 9 |
10 namespace syncer { | 10 namespace syncer { |
11 | 11 |
12 class MockInvalidationTracker; | 12 class MockInvalidationTracker; |
13 | 13 |
14 // A variant of MockInvalidation that supports acknowledgements. | 14 // A variant of MockInvalidation that supports acknowledgements. |
15 // | 15 // |
16 // With the help of a MockInvalidationTracker, this can be used to test | 16 // With the help of a MockInvalidationTracker, this can be used to test |
17 // sync's use of the Drop() and Acknowledge() methods. | 17 // sync's use of the Drop() and Acknowledge() methods. |
18 class TrackableMockInvalidation : public MockInvalidation { | 18 class TrackableMockInvalidation : public MockInvalidation { |
19 public: | 19 public: |
20 TrackableMockInvalidation(bool is_unknown_version, | 20 TrackableMockInvalidation(bool is_unknown_version, |
21 int64 version, | 21 int64 version, |
22 const std::string& payload, | 22 const std::string& payload, |
23 MockInvalidationTracker* tracker, | 23 MockInvalidationTracker* tracker, |
24 int tracking_id); | 24 int tracking_id); |
25 virtual ~TrackableMockInvalidation(); | 25 virtual ~TrackableMockInvalidation(); |
26 | 26 |
27 // Forwards notice of the acknowledgement of this invalidation to the | 27 // Forwards notice of the acknowledgement of this invalidation to the |
28 // |tracker_|. | 28 // |tracker_|. |
29 virtual void Acknowledge() OVERRIDE; | 29 virtual void Acknowledge() override; |
30 | 30 |
31 // Forwards notice of the drop of this invalidation to the |tracker_|. | 31 // Forwards notice of the drop of this invalidation to the |tracker_|. |
32 virtual void Drop() OVERRIDE; | 32 virtual void Drop() override; |
33 | 33 |
34 // Returns the integer used to identify this object with the |tracker_|. | 34 // Returns the integer used to identify this object with the |tracker_|. |
35 int GetTrackingId(); | 35 int GetTrackingId(); |
36 | 36 |
37 private: | 37 private: |
38 // The MockInvalidationTracker that initialized this object, and which keeps | 38 // The MockInvalidationTracker that initialized this object, and which keeps |
39 // track of its acknowledgement status. It is expected to outlive the | 39 // track of its acknowledgement status. It is expected to outlive the |
40 // invalidations. The data required for unit test assertions lives there. | 40 // invalidations. The data required for unit test assertions lives there. |
41 MockInvalidationTracker* tracker_; | 41 MockInvalidationTracker* tracker_; |
42 | 42 |
43 // An identifier that uniquely identifies this invalidation to its | 43 // An identifier that uniquely identifies this invalidation to its |
44 // |tracker_|. | 44 // |tracker_|. |
45 // | 45 // |
46 // This is necessary in part because invalidations may be short lived; the | 46 // This is necessary in part because invalidations may be short lived; the |
47 // invalidation may be deleted by the time we want to make assertions about | 47 // invalidation may be deleted by the time we want to make assertions about |
48 // its state. | 48 // its state. |
49 int tracking_id_; | 49 int tracking_id_; |
50 }; | 50 }; |
51 | 51 |
52 } // namespace syncer | 52 } // namespace syncer |
53 | 53 |
54 #endif // SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ | 54 #endif // SYNC_TEST_TRACKABLE_MOCK_INVALIDATION_H_ |
OLD | NEW |