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

Unified Diff: services/shell/tests/connect/connect_unittest.cc

Issue 2209943002: Eliminate outgoing InterfaceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracing
Patch Set: . Created 4 years, 4 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 | « services/shell/tests/connect/connect_test_package.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/tests/connect/connect_unittest.cc
diff --git a/services/shell/tests/connect/connect_unittest.cc b/services/shell/tests/connect/connect_unittest.cc
index 0f63add1e4143dcd738ddbfe27af58951c156ba2..8678f32f1488aa55867ca9e37aa76b95bb4ad8b9 100644
--- a/services/shell/tests/connect/connect_unittest.cc
+++ b/services/shell/tests/connect/connect_unittest.cc
@@ -84,10 +84,6 @@ class ConnectTest : public test::ServiceTest,
return connection;
}
- void set_ping_callback(const base::Closure& callback) {
- ping_callback_ = callback;
- }
-
void CompareConnectionState(
const std::string& connection_local_name,
const std::string& connection_remote_name,
@@ -104,6 +100,24 @@ class ConnectTest : public test::ServiceTest,
}
private:
+ class TestService : public test::ServiceTestClient {
+ public:
+ explicit TestService(ConnectTest* connect_test)
+ : test::ServiceTestClient(connect_test),
+ connect_test_(connect_test) {}
+ ~TestService() override {}
+
+ private:
+ bool OnConnect(Connection* connection) override {
+ connection->AddInterface<test::mojom::ExposedInterface>(connect_test_);
+ return true;
+ }
+
+ ConnectTest* connect_test_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestService);
+ };
+
// test::ServiceTest:
void SetUp() override {
test::ServiceTest::SetUp();
@@ -120,6 +134,9 @@ class ConnectTest : public test::ServiceTest,
base::Bind(&ReceiveOneString, &root_name, &run_loop));
run_loop.Run();
}
+ std::unique_ptr<Service> CreateService() override {
+ return base::WrapUnique(new TestService(this));
+ }
// InterfaceFactory<test::mojom::ExposedInterface>:
void Create(const Identity& remote_identity,
@@ -129,10 +146,8 @@ class ConnectTest : public test::ServiceTest,
void ConnectionAccepted(test::mojom::ConnectionStatePtr state) override {
connection_state_ = std::move(state);
- ping_callback_.Run();
}
- base::Closure ping_callback_;
test::mojom::ConnectionStatePtr connection_state_;
mojo::BindingSet<test::mojom::ExposedInterface> bindings_;
@@ -400,63 +415,4 @@ TEST_F(ConnectTest, AllUsersSingleton) {
}
}
-// Tests that we can expose an interface to targets on outbound connections.
-TEST_F(ConnectTest, LocalInterface) {
- // Connect to a standalone application.
- {
- test::mojom::ConnectTestServicePtr service;
- std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName);
- connection->GetInterface(&service);
- connection->AddInterface<test::mojom::ExposedInterface>(this);
-
- {
- base::RunLoop run_loop;
- EXPECT_TRUE(connection->IsPending());
- EXPECT_EQ(mojom::kInvalidInstanceID, connection->GetRemoteInstanceID());
- connection->AddConnectionCompletedClosure(
- base::Bind(&QuitLoop, &run_loop));
- run_loop.Run();
- EXPECT_FALSE(connection->IsPending());
- }
-
- {
- base::RunLoop run_loop;
- set_ping_callback(base::Bind(&QuitLoop, &run_loop));
- run_loop.Run();
- CompareConnectionState(
- kTestAppName, test_name(), test_userid(), kTestAppName,
- connection->GetRemoteIdentity().user_id());
- }
- }
-
- // Connect to an application provided by a package.
- {
- test::mojom::ConnectTestServicePtr service_a;
- std::unique_ptr<Connection> connection =
- connector()->Connect(kTestAppAName);
- connection->GetInterface(&service_a);
- connection->AddInterface<test::mojom::ExposedInterface>(this);
-
- {
- base::RunLoop run_loop;
- EXPECT_TRUE(connection->IsPending());
- EXPECT_EQ(mojom::kInvalidInstanceID, connection->GetRemoteInstanceID());
- connection->AddConnectionCompletedClosure(
- base::Bind(&QuitLoop, &run_loop));
- run_loop.Run();
- EXPECT_FALSE(connection->IsPending());
- }
-
- {
- base::RunLoop run_loop;
- set_ping_callback(base::Bind(&QuitLoop, &run_loop));
- run_loop.Run();
- CompareConnectionState(
- kTestAppAName, test_name(), test_userid(), kTestAppAName,
- connection->GetRemoteIdentity().user_id());
- }
-
- }
-}
-
} // namespace shell
« no previous file with comments | « services/shell/tests/connect/connect_test_package.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698