OLD | NEW |
| (Empty) |
1 // Copyright 2016 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/shell/background/background_shell.h" | |
6 | |
7 #include "base/run_loop.h" | |
8 #include "mojo/shell/background/tests/test.mojom.h" | |
9 #include "mojo/shell/background/tests/test_catalog_store.h" | |
10 #include "mojo/shell/public/cpp/connector.h" | |
11 #include "mojo/shell/public/cpp/shell_client.h" | |
12 #include "mojo/shell/public/cpp/shell_connection.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 namespace mojo { | |
16 namespace shell { | |
17 namespace { | |
18 | |
19 const char kTestName[] = "mojo:test-app"; | |
20 | |
21 class ShellClientImpl : public ShellClient { | |
22 public: | |
23 ShellClientImpl() {} | |
24 ~ShellClientImpl() override {} | |
25 | |
26 private: | |
27 DISALLOW_COPY_AND_ASSIGN(ShellClientImpl); | |
28 }; | |
29 | |
30 scoped_ptr<TestCatalogStore> BuildTestCatalogStore() { | |
31 scoped_ptr<base::ListValue> apps(new base::ListValue); | |
32 apps->Append(BuildPermissiveSerializedAppInfo(kTestName, "test")); | |
33 return make_scoped_ptr(new TestCatalogStore(std::move(apps))); | |
34 } | |
35 | |
36 } // namespace | |
37 | |
38 // Uses BackgroundShell to start the shell in the background and connects to | |
39 // background_shell_test_app, verifying we can send a message to the app. | |
40 // An ApplicationCatalogStore is supplied to avoid using a manifest. | |
41 #if defined(OS_ANDROID) | |
42 // TODO(crbug.com/589784): This test is disabled, as it fails | |
43 // on the Android GN bot. | |
44 #define MAYBE_Basic DISABLED_Basic | |
45 #else | |
46 #define MAYBE_Basic Basic | |
47 #endif | |
48 TEST(BackgroundShellTest, MAYBE_Basic) { | |
49 base::MessageLoop message_loop; | |
50 BackgroundShell background_shell; | |
51 scoped_ptr<BackgroundShell::InitParams> init_params( | |
52 new BackgroundShell::InitParams); | |
53 scoped_ptr<TestCatalogStore> store_ptr = BuildTestCatalogStore(); | |
54 TestCatalogStore* store = store_ptr.get(); | |
55 init_params->catalog_store = std::move(store_ptr); | |
56 background_shell.Init(std::move(init_params)); | |
57 ShellClientImpl shell_client; | |
58 ShellConnection shell_connection( | |
59 &shell_client, background_shell.CreateShellClientRequest(kTestName)); | |
60 mojom::TestServicePtr test_service; | |
61 shell_connection.connector()->ConnectToInterface( | |
62 "mojo:background_shell_test_app", &test_service); | |
63 base::RunLoop run_loop; | |
64 bool got_result = false; | |
65 test_service->Test([&run_loop, &got_result]() { | |
66 got_result = true; | |
67 run_loop.Quit(); | |
68 }); | |
69 run_loop.Run(); | |
70 EXPECT_TRUE(got_result); | |
71 EXPECT_TRUE(store->get_store_called()); | |
72 } | |
73 | |
74 } // namespace shell | |
75 } // namespace mojo | |
OLD | NEW |