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

Side by Side Diff: mojo/shell/package_apptest.cc

Issue 1701583002: Decompose Application Package Apptest a bit more. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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
(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 <stddef.h>
6 #include <stdint.h>
7
8 #include <utility>
9
10 #include "base/bind.h"
11 #include "base/macros.h"
12 #include "base/run_loop.h"
13 #include "mojo/shell/package_test.mojom.h"
14 #include "mojo/shell/public/cpp/application_test_base.h"
15 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
16
17 // Tests that multiple applications can be packaged in a single Mojo application
18 // implementing ContentHandler; that these applications can be specified by
19 // the package's manifest and are thus registered with the PackageManager.
20
21 namespace mojo {
22 namespace shell {
23 namespace {
24 void ReceiveName(std::string* out_name,
25 base::RunLoop* loop,
26 const String& name) {
27 *out_name = name;
28 loop->Quit();
29 }
30 } // namespace
31
32 using PackageApptest = mojo::test::ApplicationTestBase;
33
34 TEST_F(PackageApptest, Basic) {
35 std::set<uint32_t> ids;
36 {
37 // We need to do this to force the shell to read the test app's manifest and
38 // register aliases.
39 test::mojom::PackageTestServicePtr root_service;
40 scoped_ptr<Connection> connection =
41 shell()->Connect("mojo:package_test_package");
42 connection->GetInterface(&root_service);
43 base::RunLoop run_loop;
44 std::string root_name;
45 root_service->GetName(base::Bind(&ReceiveName, &root_name, &run_loop));
46 run_loop.Run();
47 uint32_t id = mojom::Shell::kInvalidApplicationID;
48 EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
49 ids.insert(id);
50 }
51
52 {
53 // Now subsequent connects to applications provided by the root app will be
54 // resolved correctly.
55 test::mojom::PackageTestServicePtr service_a;
56 scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_a");
57 connection->GetInterface(&service_a);
58 base::RunLoop run_loop;
59 std::string a_name;
60 service_a->GetName(base::Bind(&ReceiveName, &a_name, &run_loop));
61 run_loop.Run();
62 EXPECT_EQ("A", a_name);
63 uint32_t id = mojom::Shell::kInvalidApplicationID;
64 EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
65 ids.insert(id);
66 }
67
68 {
69 test::mojom::PackageTestServicePtr service_b;
70 scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_b");
71 connection->GetInterface(&service_b);
72 base::RunLoop run_loop;
73 std::string b_name;
74 service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop));
75 run_loop.Run();
76 EXPECT_EQ("B", b_name);
77 uint32_t id = mojom::Shell::kInvalidApplicationID;
78 EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
79 ids.insert(id);
80 }
81 }
82
83 } // namespace shell
84 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_package_apptest_app_b_manifest.json ('k') | mojo/shell/package_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698