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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/package_apptest.cc
diff --git a/mojo/shell/package_apptest.cc b/mojo/shell/package_apptest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5e2db9ba79e61a71530abfc36a4f95c078e2073d
--- /dev/null
+++ b/mojo/shell/package_apptest.cc
@@ -0,0 +1,84 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "base/run_loop.h"
+#include "mojo/shell/package_test.mojom.h"
+#include "mojo/shell/public/cpp/application_test_base.h"
+#include "mojo/shell/public/interfaces/application_manager.mojom.h"
+
+// Tests that multiple applications can be packaged in a single Mojo application
+// implementing ContentHandler; that these applications can be specified by
+// the package's manifest and are thus registered with the PackageManager.
+
+namespace mojo {
+namespace shell {
+namespace {
+void ReceiveName(std::string* out_name,
+ base::RunLoop* loop,
+ const String& name) {
+ *out_name = name;
+ loop->Quit();
+}
+} // namespace
+
+using PackageApptest = mojo::test::ApplicationTestBase;
+
+TEST_F(PackageApptest, Basic) {
+ std::set<uint32_t> ids;
+ {
+ // We need to do this to force the shell to read the test app's manifest and
+ // register aliases.
+ test::mojom::PackageTestServicePtr root_service;
+ scoped_ptr<Connection> connection =
+ shell()->Connect("mojo:package_test_package");
+ connection->GetInterface(&root_service);
+ base::RunLoop run_loop;
+ std::string root_name;
+ root_service->GetName(base::Bind(&ReceiveName, &root_name, &run_loop));
+ run_loop.Run();
+ uint32_t id = mojom::Shell::kInvalidApplicationID;
+ EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
+ ids.insert(id);
+ }
+
+ {
+ // Now subsequent connects to applications provided by the root app will be
+ // resolved correctly.
+ test::mojom::PackageTestServicePtr service_a;
+ scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_a");
+ connection->GetInterface(&service_a);
+ base::RunLoop run_loop;
+ std::string a_name;
+ service_a->GetName(base::Bind(&ReceiveName, &a_name, &run_loop));
+ run_loop.Run();
+ EXPECT_EQ("A", a_name);
+ uint32_t id = mojom::Shell::kInvalidApplicationID;
+ EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
+ ids.insert(id);
+ }
+
+ {
+ test::mojom::PackageTestServicePtr service_b;
+ scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_b");
+ connection->GetInterface(&service_b);
+ base::RunLoop run_loop;
+ std::string b_name;
+ service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop));
+ run_loop.Run();
+ EXPECT_EQ("B", b_name);
+ uint32_t id = mojom::Shell::kInvalidApplicationID;
+ EXPECT_TRUE(connection->GetRemoteApplicationID(&id));
+ ids.insert(id);
+ }
+}
+
+} // namespace shell
+} // namespace mojo
« 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