1 // Copyright 2013 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 CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ 6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ 7 8 #include <list> 9 #include <utility> 10 11 #include "base/basictypes.h" 12 #include "chrome/browser/invalidation/invalidation_service.h" 13 #include "sync/notifier/invalidator_registrar.h" 14 #include "sync/notifier/mock_ack_handler.h" 15 16 namespace syncer { 17 class Invalidation; 18 } 19 20 namespace invalidation { 21 22 // An InvalidationService that emits invalidations only when 23 // its EmitInvalidationForTest method is called. 24 class FakeInvalidationService : public InvalidationService { 25 public: 26 FakeInvalidationService(); 27 virtual ~FakeInvalidationService(); 28 29 virtual void RegisterInvalidationHandler( 30 syncer::InvalidationHandler* handler) OVERRIDE; 31 virtual void UpdateRegisteredInvalidationIds( 32 syncer::InvalidationHandler* handler, 33 const syncer::ObjectIdSet& ids) OVERRIDE; 34 virtual void UnregisterInvalidationHandler( 35 syncer::InvalidationHandler* handler) OVERRIDE; 36 37 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; 38 virtual std::string GetInvalidatorClientId() const OVERRIDE; 39 40 void SetInvalidatorState(syncer::InvalidatorState state); 41 invalidator_registrar()42 const syncer::InvalidatorRegistrar& invalidator_registrar() const { 43 return invalidator_registrar_; 44 } 45 46 void EmitInvalidationForTest(const syncer::Invalidation& invalidation); 47 48 // Emitted invalidations will be hooked up to this AckHandler. Clients can 49 // query it to assert the invalidaitons are being acked properly. 50 syncer::MockAckHandler* GetMockAckHandler(); 51 52 private: 53 std::string client_id_; 54 syncer::InvalidatorRegistrar invalidator_registrar_; 55 syncer::MockAckHandler mock_ack_handler_; 56 57 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); 58 }; 59 60 } // namespace invalidation 61 62 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ 63