OLD | NEW |
| (Empty) |
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_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ | |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST
_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/files/file_path.h" | |
12 #include "base/macros.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "components/component_updater/component_updater_service.h" | |
16 #include "content/public/test/test_browser_thread_bundle.h" | |
17 #include "testing/gmock/include/gmock/gmock.h" | |
18 #include "testing/gtest/include/gtest/gtest.h" | |
19 | |
20 namespace net { | |
21 class LocalHostTestURLRequestInterceptor; | |
22 } | |
23 | |
24 namespace update_client { | |
25 struct CrxComponent; | |
26 class InterceptorFactory; | |
27 class TestConfigurator; | |
28 class TestInstaller; | |
29 class URLRequestPostInterceptor; | |
30 } | |
31 | |
32 namespace component_updater { | |
33 | |
34 // Intercepts HTTP GET requests sent to "localhost". | |
35 typedef net::LocalHostTestURLRequestInterceptor GetInterceptor; | |
36 | |
37 class ComponentUpdaterTest : public testing::Test { | |
38 public: | |
39 enum TestComponents { | |
40 kTestComponent_abag, | |
41 kTestComponent_jebg, | |
42 kTestComponent_ihfo, | |
43 }; | |
44 | |
45 ComponentUpdaterTest(); | |
46 | |
47 ~ComponentUpdaterTest() override; | |
48 | |
49 void SetUp() override; | |
50 | |
51 void TearDown() override; | |
52 | |
53 ComponentUpdateService* component_updater(); | |
54 | |
55 // Makes the full path to a component updater test file. | |
56 const base::FilePath test_file(const char* file); | |
57 | |
58 scoped_refptr<update_client::TestConfigurator> test_configurator(); | |
59 | |
60 ComponentUpdateService::Status RegisterComponent( | |
61 update_client::CrxComponent* com, | |
62 TestComponents component, | |
63 const Version& version, | |
64 const scoped_refptr<update_client::TestInstaller>& installer); | |
65 | |
66 protected: | |
67 void RunThreads(); | |
68 void RunThreadsUntilIdle(); | |
69 | |
70 scoped_ptr<update_client::InterceptorFactory> interceptor_factory_; | |
71 | |
72 // Owned by the factory. | |
73 update_client::URLRequestPostInterceptor* post_interceptor_; | |
74 | |
75 scoped_ptr<GetInterceptor> get_interceptor_; | |
76 | |
77 private: | |
78 content::TestBrowserThreadBundle thread_bundle_; | |
79 scoped_refptr<update_client::TestConfigurator> test_config_; | |
80 scoped_ptr<ComponentUpdateService> component_updater_; | |
81 }; | |
82 | |
83 const char expected_crx_url[] = | |
84 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; | |
85 | |
86 class MockServiceObserver : public ServiceObserver { | |
87 public: | |
88 MockServiceObserver(); | |
89 ~MockServiceObserver(); | |
90 MOCK_METHOD2(OnEvent, void(Events event, const std::string&)); | |
91 }; | |
92 | |
93 class OnDemandTester { | |
94 public: | |
95 static ComponentUpdateService::Status OnDemand( | |
96 ComponentUpdateService* cus, | |
97 const std::string& component_id); | |
98 }; | |
99 | |
100 } // namespace component_updater | |
101 | |
102 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT
EST_H_ | |
OLD | NEW |