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.
5 #ifndef CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_
6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
14 #include "components/invalidation/invalidation_service.h"
15 #include "google_apis/gaia/fake_identity_provider.h"
16 #include "sync/notifier/invalidator_registrar.h"
17 #include "sync/notifier/mock_ack_handler.h"
27 namespace invalidation
{
29 class InvalidationLogger
;
31 // An InvalidationService that emits invalidations only when
32 // its EmitInvalidationForTest method is called.
33 class FakeInvalidationService
: public InvalidationService
{
35 FakeInvalidationService();
36 virtual ~FakeInvalidationService();
38 static KeyedService
* Build(content::BrowserContext
* context
);
40 virtual void RegisterInvalidationHandler(
41 syncer::InvalidationHandler
* handler
) OVERRIDE
;
42 virtual void UpdateRegisteredInvalidationIds(
43 syncer::InvalidationHandler
* handler
,
44 const syncer::ObjectIdSet
& ids
) OVERRIDE
;
45 virtual void UnregisterInvalidationHandler(
46 syncer::InvalidationHandler
* handler
) OVERRIDE
;
48 virtual syncer::InvalidatorState
GetInvalidatorState() const OVERRIDE
;
49 virtual std::string
GetInvalidatorClientId() const OVERRIDE
;
50 virtual InvalidationLogger
* GetInvalidationLogger() OVERRIDE
;
51 virtual void RequestDetailedStatus(
52 base::Callback
<void(const base::DictionaryValue
&)> caller
) const OVERRIDE
;
53 virtual IdentityProvider
* GetIdentityProvider() OVERRIDE
;
55 void SetInvalidatorState(syncer::InvalidatorState state
);
57 const syncer::InvalidatorRegistrar
& invalidator_registrar() const {
58 return invalidator_registrar_
;
61 void EmitInvalidationForTest(const syncer::Invalidation
& invalidation
);
63 // Emitted invalidations will be hooked up to this AckHandler. Clients can
64 // query it to assert the invalidaitons are being acked properly.
65 syncer::MockAckHandler
* GetMockAckHandler();
68 std::string client_id_
;
69 syncer::InvalidatorRegistrar invalidator_registrar_
;
70 syncer::MockAckHandler mock_ack_handler_
;
71 FakeProfileOAuth2TokenService token_service_
;
72 FakeIdentityProvider identity_provider_
;
74 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService
);
77 } // namespace invalidation
79 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_