Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: services/shell/background/tests/background_shell_unittest.cc

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "services/shell/background/background_shell.h" 5 #include "services/shell/background/background_shell.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 17 matching lines...) Expand all
28 private: 28 private:
29 DISALLOW_COPY_AND_ASSIGN(ShellClientImpl); 29 DISALLOW_COPY_AND_ASSIGN(ShellClientImpl);
30 }; 30 };
31 31
32 std::unique_ptr<TestCatalogStore> BuildTestCatalogStore() { 32 std::unique_ptr<TestCatalogStore> BuildTestCatalogStore() {
33 std::unique_ptr<base::ListValue> apps(new base::ListValue); 33 std::unique_ptr<base::ListValue> apps(new base::ListValue);
34 apps->Append(BuildPermissiveSerializedAppInfo(kTestName, "test")); 34 apps->Append(BuildPermissiveSerializedAppInfo(kTestName, "test"));
35 return base::WrapUnique(new TestCatalogStore(std::move(apps))); 35 return base::WrapUnique(new TestCatalogStore(std::move(apps)));
36 } 36 }
37 37
38 void SetFlagAndRunClosure(bool* flag, const base::Closure& closure) {
39 *flag = true;
40 closure.Run();
41 }
42
38 } // namespace 43 } // namespace
39 44
40 // Uses BackgroundShell to start the shell in the background and connects to 45 // Uses BackgroundShell to start the shell in the background and connects to
41 // background_shell_test_app, verifying we can send a message to the app. 46 // background_shell_test_app, verifying we can send a message to the app.
42 // An ApplicationCatalogStore is supplied to avoid using a manifest. 47 // An ApplicationCatalogStore is supplied to avoid using a manifest.
43 #if defined(OS_ANDROID) 48 #if defined(OS_ANDROID)
44 // TODO(crbug.com/589784): This test is disabled, as it fails 49 // TODO(crbug.com/589784): This test is disabled, as it fails
45 // on the Android GN bot. 50 // on the Android GN bot.
46 #define MAYBE_Basic DISABLED_Basic 51 #define MAYBE_Basic DISABLED_Basic
47 #else 52 #else
48 #define MAYBE_Basic Basic 53 #define MAYBE_Basic Basic
49 #endif 54 #endif
50 TEST(BackgroundShellTest, MAYBE_Basic) { 55 TEST(BackgroundShellTest, MAYBE_Basic) {
51 base::MessageLoop message_loop; 56 base::MessageLoop message_loop;
52 BackgroundShell background_shell; 57 BackgroundShell background_shell;
53 std::unique_ptr<BackgroundShell::InitParams> init_params( 58 std::unique_ptr<BackgroundShell::InitParams> init_params(
54 new BackgroundShell::InitParams); 59 new BackgroundShell::InitParams);
55 std::unique_ptr<TestCatalogStore> store_ptr = BuildTestCatalogStore(); 60 std::unique_ptr<TestCatalogStore> store_ptr = BuildTestCatalogStore();
56 TestCatalogStore* store = store_ptr.get(); 61 TestCatalogStore* store = store_ptr.get();
57 init_params->catalog_store = std::move(store_ptr); 62 init_params->catalog_store = std::move(store_ptr);
58 background_shell.Init(std::move(init_params)); 63 background_shell.Init(std::move(init_params));
59 ShellClientImpl shell_client; 64 ShellClientImpl shell_client;
60 ShellConnection shell_connection( 65 ShellConnection shell_connection(
61 &shell_client, background_shell.CreateShellClientRequest(kTestName)); 66 &shell_client, background_shell.CreateShellClientRequest(kTestName));
62 mojom::TestServicePtr test_service; 67 mojom::TestServicePtr test_service;
63 shell_connection.connector()->ConnectToInterface( 68 shell_connection.connector()->ConnectToInterface(
64 "mojo:background_shell_test_app", &test_service); 69 "mojo:background_shell_test_app", &test_service);
65 base::RunLoop run_loop; 70 base::RunLoop run_loop;
66 bool got_result = false; 71 bool got_result = false;
67 test_service->Test([&run_loop, &got_result]() { 72 test_service->Test(base::Bind(&SetFlagAndRunClosure, &got_result,
68 got_result = true; 73 run_loop.QuitClosure()));
69 run_loop.Quit();
70 });
71 run_loop.Run(); 74 run_loop.Run();
72 EXPECT_TRUE(got_result); 75 EXPECT_TRUE(got_result);
73 EXPECT_TRUE(store->get_store_called()); 76 EXPECT_TRUE(store->get_store_called());
74 } 77 }
75 78
76 } // namespace shell 79 } // namespace shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698