OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_API_TEST_BASE_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_TEST_BASE_H_ |
6 #define EXTENSIONS_RENDERER_API_TEST_BASE_H_ | 6 #define EXTENSIONS_RENDERER_API_TEST_BASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 private: | 85 private: |
86 void RegisterModules(); | 86 void RegisterModules(); |
87 void InitializeEnvironment(); | 87 void InitializeEnvironment(); |
88 void RunTestInner(const std::string& test_name, | 88 void RunTestInner(const std::string& test_name, |
89 const base::Closure& quit_closure); | 89 const base::Closure& quit_closure); |
90 void RunPromisesAgain(); | 90 void RunPromisesAgain(); |
91 | 91 |
92 ModuleSystemTestEnvironment* env_; | 92 ModuleSystemTestEnvironment* env_; |
93 TestServiceProvider* service_provider_; | 93 TestServiceProvider* service_provider_; |
94 scoped_ptr<V8SchemaRegistry> v8_schema_registry_; | 94 std::unique_ptr<V8SchemaRegistry> v8_schema_registry_; |
95 }; | 95 }; |
96 | 96 |
97 // A base class for unit testing apps/extensions API custom bindings implemented | 97 // A base class for unit testing apps/extensions API custom bindings implemented |
98 // on Mojo services. To use: | 98 // on Mojo services. To use: |
99 // 1. Register test Mojo service implementations on service_provider(). | 99 // 1. Register test Mojo service implementations on service_provider(). |
100 // 2. Write JS tests in extensions/test/data/test_file.js. | 100 // 2. Write JS tests in extensions/test/data/test_file.js. |
101 // 3. Write one C++ test function for each JS test containing | 101 // 3. Write one C++ test function for each JS test containing |
102 // RunTest("test_file.js", "testFunctionName"). | 102 // RunTest("test_file.js", "testFunctionName"). |
103 // See extensions/renderer/api_test_base_unittest.cc and | 103 // See extensions/renderer/api_test_base_unittest.cc and |
104 // extensions/test/data/api_test_base_unittest.js for sample usage. | 104 // extensions/test/data/api_test_base_unittest.js for sample usage. |
105 class ApiTestBase : public ModuleSystemTest { | 105 class ApiTestBase : public ModuleSystemTest { |
106 protected: | 106 protected: |
107 ApiTestBase(); | 107 ApiTestBase(); |
108 ~ApiTestBase() override; | 108 ~ApiTestBase() override; |
109 void SetUp() override; | 109 void SetUp() override; |
110 void RunTest(const std::string& file_name, const std::string& test_name); | 110 void RunTest(const std::string& file_name, const std::string& test_name); |
111 | 111 |
112 ApiTestEnvironment* api_test_env() { return test_env_.get(); } | 112 ApiTestEnvironment* api_test_env() { return test_env_.get(); } |
113 TestServiceProvider* service_provider() { | 113 TestServiceProvider* service_provider() { |
114 return test_env_->service_provider(); | 114 return test_env_->service_provider(); |
115 } | 115 } |
116 | 116 |
117 private: | 117 private: |
118 base::MessageLoop message_loop_; | 118 base::MessageLoop message_loop_; |
119 scoped_ptr<ApiTestEnvironment> test_env_; | 119 std::unique_ptr<ApiTestEnvironment> test_env_; |
120 }; | 120 }; |
121 | 121 |
122 } // namespace extensions | 122 } // namespace extensions |
123 | 123 |
124 #endif // EXTENSIONS_RENDERER_API_TEST_BASE_H_ | 124 #endif // EXTENSIONS_RENDERER_API_TEST_BASE_H_ |
OLD | NEW |