Extract code handling PrinterProviderAPI from PrintPreviewHandler
[chromium-blink-merge.git] / chrome / browser / component_updater / test / component_updater_service_unittest.h
blobbb035ced23fff4a4e5c534d4d8d47414971a1e36
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_
8 #include <string>
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"
19 namespace net {
20 class LocalHostTestURLRequestInterceptor;
23 namespace update_client {
24 struct CrxComponent;
25 class InterceptorFactory;
26 class TestConfigurator;
27 class TestInstaller;
28 class URLRequestPostInterceptor;
31 namespace component_updater {
33 // Intercepts HTTP GET requests sent to "localhost".
34 typedef net::LocalHostTestURLRequestInterceptor GetInterceptor;
36 class ComponentUpdaterTest : public testing::Test {
37 public:
38 enum TestComponents {
39 kTestComponent_abag,
40 kTestComponent_jebg,
41 kTestComponent_ihfo,
44 ComponentUpdaterTest();
46 ~ComponentUpdaterTest() override;
48 void SetUp() override;
50 void TearDown() override;
52 ComponentUpdateService* component_updater();
54 // Makes the full path to a component updater test file.
55 const base::FilePath test_file(const char* file);
57 update_client::TestConfigurator* test_configurator();
59 ComponentUpdateService::Status RegisterComponent(
60 update_client::CrxComponent* com,
61 TestComponents component,
62 const Version& version,
63 const scoped_refptr<update_client::TestInstaller>& installer);
65 protected:
66 void RunThreads();
67 void RunThreadsUntilIdle();
69 scoped_ptr<update_client::InterceptorFactory> interceptor_factory_;
71 // Owned by the factory.
72 update_client::URLRequestPostInterceptor* post_interceptor_;
74 scoped_ptr<GetInterceptor> get_interceptor_;
76 private:
77 update_client::TestConfigurator* test_config_;
78 content::TestBrowserThreadBundle thread_bundle_;
79 scoped_ptr<ComponentUpdateService> component_updater_;
82 const char expected_crx_url[] =
83 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
85 class MockServiceObserver : public ServiceObserver {
86 public:
87 MockServiceObserver();
88 ~MockServiceObserver();
89 MOCK_METHOD2(OnEvent, void(Events event, const std::string&));
92 class OnDemandTester {
93 public:
94 static ComponentUpdateService::Status OnDemand(
95 ComponentUpdateService* cus,
96 const std::string& component_id);
99 } // namespace component_updater
101 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_