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