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/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/component_updater/component_updater_service.h"
15 #include "components/component_updater/test/test_configurator.h"
16 #include "components/component_updater/test/url_request_post_interceptor.h"
17 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "content/test/net/url_request_prepackaged_interceptor.h"
19 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h"
23 namespace component_updater
{
27 // Intercepts HTTP GET requests sent to "localhost".
28 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor
;
30 class ComponentUpdaterTest
: public testing::Test
{
38 ComponentUpdaterTest();
40 virtual ~ComponentUpdaterTest();
44 virtual void TearDown();
46 ComponentUpdateService
* component_updater();
48 // Makes the full path to a component updater test file.
49 const base::FilePath
test_file(const char* file
);
51 TestConfigurator
* test_configurator();
53 ComponentUpdateService::Status
RegisterComponent(CrxComponent
* com
,
54 TestComponents component
,
55 const Version
& version
,
56 TestInstaller
* installer
);
60 void RunThreadsUntilIdle();
62 scoped_ptr
<InterceptorFactory
> interceptor_factory_
;
63 URLRequestPostInterceptor
* post_interceptor_
; // Owned by the factory.
65 scoped_ptr
<GetInterceptor
> get_interceptor_
;
68 TestConfigurator
* test_config_
;
69 content::TestBrowserThreadBundle thread_bundle_
;
70 scoped_ptr
<ComponentUpdateService
> component_updater_
;
73 const char expected_crx_url
[] =
74 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
76 class MockServiceObserver
: public ServiceObserver
{
78 MockServiceObserver();
79 ~MockServiceObserver();
80 MOCK_METHOD2(OnEvent
, void(Events event
, const std::string
&));
83 class OnDemandTester
{
85 static ComponentUpdateService::Status
OnDemand(
86 ComponentUpdateService
* cus
,
87 const std::string
& component_id
);
90 } // namespace component_updater
92 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_