Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / invalidation / impl / fake_invalidator_unittest.cc
blob3e9fa7c1c5a1e9ca5bfffd2db853cdb8fc0c90d3
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.
5 #include "base/compiler_specific.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "components/invalidation/impl/fake_invalidator.h"
8 #include "components/invalidation/impl/invalidator_test_template.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace syncer {
13 namespace {
15 class FakeInvalidatorTestDelegate {
16 public:
17 FakeInvalidatorTestDelegate() {}
19 ~FakeInvalidatorTestDelegate() {
20 DestroyInvalidator();
23 void CreateInvalidator(
24 const std::string& invalidator_client_id,
25 const std::string& initial_state,
26 const base::WeakPtr<InvalidationStateTracker>&
27 invalidation_state_tracker) {
28 DCHECK(!invalidator_.get());
29 invalidator_.reset(new FakeInvalidator());
32 FakeInvalidator* GetInvalidator() {
33 return invalidator_.get();
36 void DestroyInvalidator() {
37 invalidator_.reset();
40 void WaitForInvalidator() {
41 // Do Nothing.
44 void TriggerOnInvalidatorStateChange(InvalidatorState state) {
45 invalidator_->EmitOnInvalidatorStateChange(state);
48 void TriggerOnIncomingInvalidation(
49 const ObjectIdInvalidationMap& invalidation_map) {
50 invalidator_->EmitOnIncomingInvalidation(invalidation_map);
53 private:
54 scoped_ptr<FakeInvalidator> invalidator_;
57 INSTANTIATE_TYPED_TEST_CASE_P(
58 FakeInvalidatorTest, InvalidatorTest,
59 FakeInvalidatorTestDelegate);
61 } // namespace
63 } // namespace syncer