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 #include "base/at_exit.h" |
5 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
6 #include "mojo/public/cpp/application/application.h" | 7 #include "mojo/public/cpp/application/application.h" |
7 #include "mojo/public/cpp/environment/environment.h" | |
8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
9 #include "mojo/service_manager/service_loader.h" | 9 #include "mojo/service_manager/service_loader.h" |
10 #include "mojo/service_manager/service_manager.h" | 10 #include "mojo/service_manager/service_manager.h" |
11 #include "mojo/service_manager/test.mojom.h" | 11 #include "mojo/service_manager/test.mojom.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char kTestURLString[] = "test:testService"; | 17 const char kTestURLString[] = "test:testService"; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 test_client_.reset(NULL); | 235 test_client_.reset(NULL); |
236 service_manager_.reset(NULL); | 236 service_manager_.reset(NULL); |
237 } | 237 } |
238 | 238 |
239 bool HasFactoryForTestURL() { | 239 bool HasFactoryForTestURL() { |
240 ServiceManager::TestAPI manager_test_api(service_manager_.get()); | 240 ServiceManager::TestAPI manager_test_api(service_manager_.get()); |
241 return manager_test_api.HasFactoryForURL(GURL(kTestURLString)); | 241 return manager_test_api.HasFactoryForURL(GURL(kTestURLString)); |
242 } | 242 } |
243 | 243 |
244 protected: | 244 protected: |
245 mojo::Environment env_; | 245 base::ShadowingAtExitManager at_exit_; |
246 base::MessageLoop loop_; | 246 base::MessageLoop loop_; |
247 TestContext context_; | 247 TestContext context_; |
248 scoped_ptr<TestClientImpl> test_client_; | 248 scoped_ptr<TestClientImpl> test_client_; |
249 scoped_ptr<ServiceManager> service_manager_; | 249 scoped_ptr<ServiceManager> service_manager_; |
250 DISALLOW_COPY_AND_ASSIGN(ServiceManagerTest); | 250 DISALLOW_COPY_AND_ASSIGN(ServiceManagerTest); |
251 }; | 251 }; |
252 | 252 |
253 TEST_F(ServiceManagerTest, Basic) { | 253 TEST_F(ServiceManagerTest, Basic) { |
254 test_client_->Test("test"); | 254 test_client_->Test("test"); |
255 loop_.Run(); | 255 loop_.Run(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 std::string url("test:test3"); | 375 std::string url("test:test3"); |
376 TestServicePtr test_service; | 376 TestServicePtr test_service; |
377 sm.ConnectTo(GURL(url), &test_service, GURL()); | 377 sm.ConnectTo(GURL(url), &test_service, GURL()); |
378 EXPECT_EQ(1, interceptor.call_count()); | 378 EXPECT_EQ(1, interceptor.call_count()); |
379 EXPECT_EQ(url, interceptor.url_spec()); | 379 EXPECT_EQ(url, interceptor.url_spec()); |
380 EXPECT_EQ(1, default_loader->num_loads()); | 380 EXPECT_EQ(1, default_loader->num_loads()); |
381 } | 381 } |
382 | 382 |
383 } // namespace mojo | 383 } // namespace mojo |
OLD | NEW |