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

Side by Side Diff: mojo/shell/tests/application_manager_unittest.cc

Issue 1725353003: Eliminate mojo::Shell client lib class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@15connector
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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/application_manager.h" 5 #include "mojo/shell/application_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h" 15 #include "mojo/public/cpp/bindings/strong_binding.h"
16 #include "mojo/services/package_manager/package_manager.h" 16 #include "mojo/services/package_manager/package_manager.h"
17 #include "mojo/shell/application_loader.h" 17 #include "mojo/shell/application_loader.h"
18 #include "mojo/shell/connect_util.h" 18 #include "mojo/shell/connect_util.h"
19 #include "mojo/shell/public/cpp/connector.h"
19 #include "mojo/shell/public/cpp/interface_factory.h" 20 #include "mojo/shell/public/cpp/interface_factory.h"
20 #include "mojo/shell/public/cpp/shell_client.h" 21 #include "mojo/shell/public/cpp/shell_client.h"
21 #include "mojo/shell/public/cpp/shell_connection.h" 22 #include "mojo/shell/public/cpp/shell_connection.h"
22 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 23 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
23 #include "mojo/shell/tests/test.mojom.h" 24 #include "mojo/shell/tests/test.mojom.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 namespace mojo { 27 namespace mojo {
27 namespace shell { 28 namespace shell {
28 namespace test { 29 namespace test {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 int num_c_deletes_; 239 int num_c_deletes_;
239 bool tester_called_quit_; 240 bool tester_called_quit_;
240 bool a_called_quit_; 241 bool a_called_quit_;
241 242
242 base::MessageLoop* loop_; 243 base::MessageLoop* loop_;
243 }; 244 };
244 245
245 // Used to test that the requestor url will be correctly passed. 246 // Used to test that the requestor url will be correctly passed.
246 class TestAImpl : public TestA { 247 class TestAImpl : public TestA {
247 public: 248 public:
248 TestAImpl(Shell* shell, 249 TestAImpl(Connector* connector,
249 TesterContext* test_context, 250 TesterContext* test_context,
250 InterfaceRequest<TestA> request, 251 InterfaceRequest<TestA> request,
251 InterfaceFactory<TestC>* factory) 252 InterfaceFactory<TestC>* factory)
252 : test_context_(test_context), binding_(this, std::move(request)) { 253 : test_context_(test_context), binding_(this, std::move(request)) {
253 connection_ = shell->Connect(kTestBURLString); 254 connection_ = connector->Connect(kTestBURLString);
254 connection_->AddInterface<TestC>(factory); 255 connection_->AddInterface<TestC>(factory);
255 connection_->GetInterface(&b_); 256 connection_->GetInterface(&b_);
256 } 257 }
257 258
258 ~TestAImpl() override { 259 ~TestAImpl() override {
259 test_context_->IncrementNumADeletes(); 260 test_context_->IncrementNumADeletes();
260 if (base::MessageLoop::current()->is_running()) 261 if (base::MessageLoop::current()->is_running())
261 Quit(); 262 Quit();
262 } 263 }
263 264
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 if (connection->GetRemoteApplicationURL() == kTestAURLString) 362 if (connection->GetRemoteApplicationURL() == kTestAURLString)
362 connection->AddInterface<TestB>(this); 363 connection->AddInterface<TestB>(this);
363 else 364 else
364 connection->AddInterface<TestA>(this); 365 connection->AddInterface<TestA>(this);
365 return true; 366 return true;
366 } 367 }
367 368
368 void Create(Connection* connection, 369 void Create(Connection* connection,
369 InterfaceRequest<TestA> request) override { 370 InterfaceRequest<TestA> request) override {
370 a_bindings_.push_back( 371 a_bindings_.push_back(
371 new TestAImpl(app_.get(), context_, std::move(request), this)); 372 new TestAImpl(app_->connector(), context_, std::move(request), this));
372 } 373 }
373 374
374 void Create(Connection* connection, 375 void Create(Connection* connection,
375 InterfaceRequest<TestB> request) override { 376 InterfaceRequest<TestB> request) override {
376 new TestBImpl(connection, context_, std::move(request)); 377 new TestBImpl(connection, context_, std::move(request));
377 } 378 }
378 379
379 void Create(Connection* connection, 380 void Create(Connection* connection,
380 InterfaceRequest<TestC> request) override { 381 InterfaceRequest<TestC> request) override {
381 new TestCImpl(connection, context_, std::move(request)); 382 new TestCImpl(connection, context_, std::move(request));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 EXPECT_EQ(2, test_loader_->num_loads()); 626 EXPECT_EQ(2, test_loader_->num_loads());
626 627
627 // A different identity because the domain is different. 628 // A different identity because the domain is different.
628 ConnectToInterface(GURL("test:bar"), &test_service); 629 ConnectToInterface(GURL("test:bar"), &test_service);
629 EXPECT_EQ(3, test_loader_->num_loads()); 630 EXPECT_EQ(3, test_loader_->num_loads());
630 } 631 }
631 632
632 } // namespace test 633 } // namespace test
633 } // namespace shell 634 } // namespace shell
634 } // namespace mojo 635 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/tests/application_manager_apptest_target.cc ('k') | mojo/shell/tests/capability_filter_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698