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