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

Side by Side Diff: mojo/shell/fetcher/about_fetcher_unittest.cc

Issue 1675153002: ApplicationImpl->ShellConnection, mojom::Application->mojom::ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ci2
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
« no previous file with comments | « mojo/shell/capability_filter_test.cc ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/fetcher/about_fetcher.h" 5 #include "mojo/shell/fetcher/about_fetcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "mojo/common/weak_binding_set.h" 17 #include "mojo/common/weak_binding_set.h"
18 #include "mojo/shell/application_loader.h" 18 #include "mojo/shell/application_loader.h"
19 #include "mojo/shell/application_manager.h" 19 #include "mojo/shell/application_manager.h"
20 #include "mojo/shell/package_manager/package_manager_impl.h" 20 #include "mojo/shell/package_manager/package_manager_impl.h"
21 #include "mojo/shell/public/cpp/application_impl.h"
22 #include "mojo/shell/public/cpp/interface_factory.h" 21 #include "mojo/shell/public/cpp/interface_factory.h"
23 #include "mojo/shell/public/cpp/shell_client.h" 22 #include "mojo/shell/public/cpp/shell_client.h"
23 #include "mojo/shell/public/cpp/shell_connection.h"
24 #include "mojo/shell/public/interfaces/content_handler.mojom.h" 24 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
25 #include "mojo/util/filename_util.h" 25 #include "mojo/util/filename_util.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 namespace mojo { 28 namespace mojo {
29 namespace shell { 29 namespace shell {
30 namespace { 30 namespace {
31 31
32 class TestContentHandler : public ShellClient, 32 class TestContentHandler : public ShellClient,
33 public InterfaceFactory<mojom::ContentHandler>, 33 public InterfaceFactory<mojom::ContentHandler>,
(...skipping 14 matching lines...) Expand all
48 } 48 }
49 49
50 // Overridden from InterfaceFactory<mojom::ContentHandler>: 50 // Overridden from InterfaceFactory<mojom::ContentHandler>:
51 void Create(Connection* connection, 51 void Create(Connection* connection,
52 InterfaceRequest<mojom::ContentHandler> request) override { 52 InterfaceRequest<mojom::ContentHandler> request) override {
53 bindings_.AddBinding(this, std::move(request)); 53 bindings_.AddBinding(this, std::move(request));
54 } 54 }
55 55
56 // Overridden from mojom::ContentHandler: 56 // Overridden from mojom::ContentHandler:
57 void StartApplication( 57 void StartApplication(
58 InterfaceRequest<mojom::Application> application, 58 InterfaceRequest<mojom::ShellClient> request,
59 URLResponsePtr response, 59 URLResponsePtr response,
60 const Callback<void()>& destruct_callback) override { 60 const Callback<void()>& destruct_callback) override {
61 response_number_++; 61 response_number_++;
62 latest_response_ = std::move(response); 62 latest_response_ = std::move(response);
63 destruct_callback.Run(); 63 destruct_callback.Run();
64 64
65 // Drop |application| request. This results in the application manager 65 // Drop |application| request. This results in the application manager
66 // dropping the ServiceProvider interface request provided by the client 66 // dropping the ServiceProvider interface request provided by the client
67 // who made the ConnectToApplication() call. Therefore the client could 67 // who made the ConnectToApplication() call. Therefore the client could
68 // listen for connection error of the ServiceProvider interface to learn 68 // listen for connection error of the ServiceProvider interface to learn
69 // that StartApplication() has been called. 69 // that StartApplication() has been called.
70 } 70 }
71 71
72 size_t response_number_; 72 size_t response_number_;
73 URLResponsePtr latest_response_; 73 URLResponsePtr latest_response_;
74 WeakBindingSet<mojom::ContentHandler> bindings_; 74 WeakBindingSet<mojom::ContentHandler> bindings_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(TestContentHandler); 76 DISALLOW_COPY_AND_ASSIGN(TestContentHandler);
77 }; 77 };
78 78
79 class TestLoader : public ApplicationLoader { 79 class TestLoader : public ApplicationLoader {
80 public: 80 public:
81 explicit TestLoader(ShellClient* delegate) : delegate_(delegate) {} 81 explicit TestLoader(ShellClient* delegate) : delegate_(delegate) {}
82 ~TestLoader() override {} 82 ~TestLoader() override {}
83 83
84 private: 84 private:
85 // Overridden from ApplicationLoader: 85 // Overridden from ApplicationLoader:
86 void Load(const GURL& url, 86 void Load(const GURL& url,
87 InterfaceRequest<mojom::Application> request) override { 87 InterfaceRequest<mojom::ShellClient> request) override {
88 app_.reset(new ApplicationImpl(delegate_, std::move(request))); 88 app_.reset(new ShellConnection(delegate_, std::move(request)));
89 } 89 }
90 90
91 ShellClient* delegate_; 91 ShellClient* delegate_;
92 scoped_ptr<ApplicationImpl> app_; 92 scoped_ptr<ShellConnection> app_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(TestLoader); 94 DISALLOW_COPY_AND_ASSIGN(TestLoader);
95 }; 95 };
96 96
97 class AboutFetcherTest : public testing::Test { 97 class AboutFetcherTest : public testing::Test {
98 public: 98 public:
99 AboutFetcherTest() {} 99 AboutFetcherTest() {}
100 ~AboutFetcherTest() override {} 100 ~AboutFetcherTest() override {}
101 101
102 protected: 102 protected:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 const URLResponse* response = html_content_handler()->latest_response(); 172 const URLResponse* response = html_content_handler()->latest_response();
173 EXPECT_EQ("about:some_unrecognized_url", response->url); 173 EXPECT_EQ("about:some_unrecognized_url", response->url);
174 EXPECT_EQ(404u, response->status_code); 174 EXPECT_EQ(404u, response->status_code);
175 EXPECT_EQ("text/html", response->mime_type); 175 EXPECT_EQ("text/html", response->mime_type);
176 EXPECT_FALSE(response->body.is_valid()); 176 EXPECT_FALSE(response->body.is_valid());
177 } 177 }
178 178
179 } // namespace 179 } // namespace
180 } // namespace shell 180 } // namespace shell
181 } // namespace mojo 181 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/capability_filter_test.cc ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698