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_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/component_updater/component_updater_service.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h"
20 class LocalHostTestURLRequestInterceptor
;
23 namespace component_updater
{
25 class InterceptorFactory
;
26 class TestConfigurator
;
28 class URLRequestPostInterceptor
;
30 // Intercepts HTTP GET requests sent to "localhost".
31 typedef net::LocalHostTestURLRequestInterceptor GetInterceptor
;
33 class ComponentUpdaterTest
: public testing::Test
{
41 ComponentUpdaterTest();
43 virtual ~ComponentUpdaterTest();
47 virtual void TearDown();
49 ComponentUpdateService
* component_updater();
51 // Makes the full path to a component updater test file.
52 const base::FilePath
test_file(const char* file
);
54 TestConfigurator
* test_configurator();
56 ComponentUpdateService::Status
RegisterComponent(CrxComponent
* com
,
57 TestComponents component
,
58 const Version
& version
,
59 TestInstaller
* installer
);
63 void RunThreadsUntilIdle();
65 scoped_ptr
<InterceptorFactory
> interceptor_factory_
;
66 URLRequestPostInterceptor
* post_interceptor_
; // Owned by the factory.
68 scoped_ptr
<GetInterceptor
> get_interceptor_
;
71 TestConfigurator
* test_config_
;
72 content::TestBrowserThreadBundle thread_bundle_
;
73 scoped_ptr
<ComponentUpdateService
> component_updater_
;
76 const char expected_crx_url
[] =
77 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
79 class MockServiceObserver
: public ServiceObserver
{
81 MockServiceObserver();
82 ~MockServiceObserver();
83 MOCK_METHOD2(OnEvent
, void(Events event
, const std::string
&));
86 class OnDemandTester
{
88 static ComponentUpdateService::Status
OnDemand(
89 ComponentUpdateService
* cus
,
90 const std::string
& component_id
);
93 } // namespace component_updater
95 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_