| 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 "mojo/service_manager/background_shell_service_loader.h" | 5 #include "mojo/service_manager/background_shell_service_loader.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class DummyLoader : public ServiceLoader { | 13 class DummyLoader : public ServiceLoader { |
| 14 public: | 14 public: |
| 15 DummyLoader() : simulate_app_quit_(true) {} | 15 DummyLoader() : simulate_app_quit_(true) {} |
| 16 virtual ~DummyLoader() {} | 16 virtual ~DummyLoader() {} |
| 17 | 17 |
| 18 // ServiceLoader overrides: | 18 // ServiceLoader overrides: |
| 19 virtual void Load(ServiceManager* manager, | 19 virtual void LoadService(ServiceManager* manager, |
| 20 const GURL& url, | 20 const GURL& url, |
| 21 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE { | 21 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
| 22 if (simulate_app_quit_) | 22 if (simulate_app_quit_) |
| 23 base::MessageLoop::current()->Quit(); | 23 base::MessageLoop::current()->Quit(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void OnServiceError(ServiceManager* manager, | 26 virtual void OnServiceError(ServiceManager* manager, |
| 27 const GURL& url) OVERRIDE { | 27 const GURL& url) OVERRIDE { |
| 28 } | 28 } |
| 29 | 29 |
| 30 void DontSimulateAppQuit() { simulate_app_quit_ = false; } | 30 void DontSimulateAppQuit() { simulate_app_quit_ = false; } |
| 31 | 31 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 base::MessageLoop::TYPE_DEFAULT); | 42 base::MessageLoop::TYPE_DEFAULT); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Tests that the loader can load a service that is well behaved (quits | 45 // Tests that the loader can load a service that is well behaved (quits |
| 46 // itself). | 46 // itself). |
| 47 TEST(BackgroundShellServiceLoaderTest, Load) { | 47 TEST(BackgroundShellServiceLoaderTest, Load) { |
| 48 scoped_ptr<ServiceLoader> real_loader(new DummyLoader()); | 48 scoped_ptr<ServiceLoader> real_loader(new DummyLoader()); |
| 49 BackgroundShellServiceLoader loader(real_loader.Pass(), "test", | 49 BackgroundShellServiceLoader loader(real_loader.Pass(), "test", |
| 50 base::MessageLoop::TYPE_DEFAULT); | 50 base::MessageLoop::TYPE_DEFAULT); |
| 51 MessagePipe dummy; | 51 MessagePipe dummy; |
| 52 scoped_refptr<ServiceLoader::SimpleLoadCallbacks> callbacks( | 52 loader.LoadService(NULL, GURL(), dummy.handle0.Pass()); |
| 53 new ServiceLoader::SimpleLoadCallbacks(dummy.handle0.Pass())); | |
| 54 loader.Load(NULL, GURL(), callbacks); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace mojo | 55 } // namespace mojo |
| OLD | NEW |