| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/shell/background/background_shell.h" | 5 #include "mojo/shell/background/background_shell.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "mojo/shell/background/tests/test.mojom.h" | 8 #include "mojo/shell/background/tests/test.mojom.h" |
| 9 #include "mojo/shell/background/tests/test_application_catalog_store.h" | 9 #include "mojo/shell/background/tests/test_application_catalog_store.h" |
| 10 #include "mojo/shell/public/cpp/connector.h" |
| 10 #include "mojo/shell/public/cpp/shell_client.h" | 11 #include "mojo/shell/public/cpp/shell_client.h" |
| 11 #include "mojo/shell/public/cpp/shell_connection.h" | 12 #include "mojo/shell/public/cpp/shell_connection.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace shell { | 17 namespace shell { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const char kTestUrl[] = "mojo:test-app"; | 20 const char kTestUrl[] = "mojo:test-app"; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 scoped_ptr<TestApplicationCatalogStore> store_ptr = | 49 scoped_ptr<TestApplicationCatalogStore> store_ptr = |
| 49 BuildTestApplicationCatalogStore(); | 50 BuildTestApplicationCatalogStore(); |
| 50 TestApplicationCatalogStore* store = store_ptr.get(); | 51 TestApplicationCatalogStore* store = store_ptr.get(); |
| 51 init_params->app_catalog = std::move(store_ptr); | 52 init_params->app_catalog = std::move(store_ptr); |
| 52 background_shell.Init(std::move(init_params)); | 53 background_shell.Init(std::move(init_params)); |
| 53 ShellClientImpl shell_client; | 54 ShellClientImpl shell_client; |
| 54 ShellConnection shell_connection( | 55 ShellConnection shell_connection( |
| 55 &shell_client, background_shell.CreateShellClientRequest(GURL(kTestUrl))); | 56 &shell_client, background_shell.CreateShellClientRequest(GURL(kTestUrl))); |
| 56 shell_connection.WaitForInitialize(); | 57 shell_connection.WaitForInitialize(); |
| 57 mojom::TestServicePtr test_service; | 58 mojom::TestServicePtr test_service; |
| 58 static_cast<Shell*>(&shell_connection) | 59 shell_connection.connector()->ConnectToInterface( |
| 59 ->ConnectToInterface("mojo:background_shell_test_app", &test_service); | 60 "mojo:background_shell_test_app", &test_service); |
| 60 base::RunLoop run_loop; | 61 base::RunLoop run_loop; |
| 61 bool got_result = false; | 62 bool got_result = false; |
| 62 test_service->Test([&run_loop, &got_result]() { | 63 test_service->Test([&run_loop, &got_result]() { |
| 63 got_result = true; | 64 got_result = true; |
| 64 run_loop.Quit(); | 65 run_loop.Quit(); |
| 65 }); | 66 }); |
| 66 run_loop.Run(); | 67 run_loop.Run(); |
| 67 EXPECT_TRUE(got_result); | 68 EXPECT_TRUE(got_result); |
| 68 EXPECT_TRUE(store->get_store_called()); | 69 EXPECT_TRUE(store->get_store_called()); |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace shell | 72 } // namespace shell |
| 72 } // namespace mojo | 73 } // namespace mojo |
| OLD | NEW |