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