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 "shell/android/background_application_loader.h" | 5 #include "shell/android/background_application_loader.h" |
6 | 6 |
| 7 #include "mojo/public/interfaces/application/application.mojom.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 namespace mojo { | 10 namespace mojo { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 class DummyLoader : public ApplicationLoader { | 14 class DummyLoader : public ApplicationLoader { |
14 public: | 15 public: |
15 DummyLoader() : simulate_app_quit_(true) {} | 16 DummyLoader() : simulate_app_quit_(true) {} |
16 ~DummyLoader() override {} | 17 ~DummyLoader() override {} |
17 | 18 |
18 // ApplicationLoader overrides: | 19 // ApplicationLoader overrides: |
19 void Load(ApplicationManager* manager, | 20 void Load(ApplicationManager* manager, |
20 const GURL& url, | 21 const GURL& url, |
21 ShellPtr shell, | 22 InterfaceRequest<Application> application_request, |
22 LoadCallback callback) override { | 23 LoadCallback callback) override { |
23 if (simulate_app_quit_) | 24 if (simulate_app_quit_) |
24 base::MessageLoop::current()->Quit(); | 25 base::MessageLoop::current()->Quit(); |
25 } | 26 } |
26 | 27 |
27 void OnApplicationError(ApplicationManager* manager, | 28 void OnApplicationError(ApplicationManager* manager, |
28 const GURL& url) override {} | 29 const GURL& url) override {} |
29 | 30 |
30 void DontSimulateAppQuit() { simulate_app_quit_ = false; } | 31 void DontSimulateAppQuit() { simulate_app_quit_ = false; } |
31 | 32 |
32 private: | 33 private: |
33 bool simulate_app_quit_; | 34 bool simulate_app_quit_; |
34 }; | 35 }; |
35 | 36 |
36 } // namespace | 37 } // namespace |
37 | 38 |
38 // Tests that the loader can start and stop gracefully. | 39 // Tests that the loader can start and stop gracefully. |
39 TEST(BackgroundApplicationLoaderTest, StartStop) { | 40 TEST(BackgroundApplicationLoaderTest, StartStop) { |
40 scoped_ptr<ApplicationLoader> real_loader(new DummyLoader()); | 41 scoped_ptr<ApplicationLoader> real_loader(new DummyLoader()); |
41 BackgroundApplicationLoader loader(real_loader.Pass(), "test", | 42 BackgroundApplicationLoader loader(real_loader.Pass(), "test", |
42 base::MessageLoop::TYPE_DEFAULT); | 43 base::MessageLoop::TYPE_DEFAULT); |
43 } | 44 } |
44 | 45 |
45 // Tests that the loader can load a service that is well behaved (quits | 46 // Tests that the loader can load a service that is well behaved (quits |
46 // itself). | 47 // itself). |
47 TEST(BackgroundApplicationLoaderTest, Load) { | 48 TEST(BackgroundApplicationLoaderTest, Load) { |
48 scoped_ptr<ApplicationLoader> real_loader(new DummyLoader()); | 49 scoped_ptr<ApplicationLoader> real_loader(new DummyLoader()); |
49 BackgroundApplicationLoader loader(real_loader.Pass(), "test", | 50 BackgroundApplicationLoader loader(real_loader.Pass(), "test", |
50 base::MessageLoop::TYPE_DEFAULT); | 51 base::MessageLoop::TYPE_DEFAULT); |
51 ShellPtr shell; | 52 ApplicationPtr application; |
52 auto dummy = GetProxy(&shell); | 53 loader.Load(NULL, GURL(), GetProxy(&application), |
53 loader.Load(NULL, GURL(), shell.Pass(), | |
54 ApplicationLoader::SimpleLoadCallback()); | 54 ApplicationLoader::SimpleLoadCallback()); |
55 } | 55 } |
56 | 56 |
57 } // namespace mojo | 57 } // namespace mojo |
OLD | NEW |