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

Side by Side Diff: ios/web/webui/web_ui_mojo_inttest.mm

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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 | « ios/web/webui/mojo_facade_unittest.mm ('k') | mash/app_driver/app_driver.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 2016 The Chromium Authors. All rights reserved. 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 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 <memory> 5 #include <memory>
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #import "base/test/ios/wait_util.h" 8 #import "base/test/ios/wait_util.h"
9 #import "ios/web/public/navigation_manager.h" 9 #import "ios/web/public/navigation_manager.h"
10 #include "ios/web/public/web_ui_ios_data_source.h" 10 #include "ios/web/public/web_ui_ios_data_source.h"
(...skipping 19 matching lines...) Expand all
30 const char kTestWebUIURLHost[] = "testwebui"; 30 const char kTestWebUIURLHost[] = "testwebui";
31 31
32 // UI handler class which communicates with test WebUI page as follows: 32 // UI handler class which communicates with test WebUI page as follows:
33 // - page sends "syn" message to |TestUIHandler| 33 // - page sends "syn" message to |TestUIHandler|
34 // - |TestUIHandler| replies with "ack" message 34 // - |TestUIHandler| replies with "ack" message
35 // - page replies back with "fin" 35 // - page replies back with "fin"
36 // 36 //
37 // Once "fin" is received |IsFinReceived()| call will return true, indicating 37 // Once "fin" is received |IsFinReceived()| call will return true, indicating
38 // that communication was successful. See test WebUI page code here: 38 // that communication was successful. See test WebUI page code here:
39 // ios/web/test/data/mojo_test.js 39 // ios/web/test/data/mojo_test.js
40 class TestUIHandler : public TestUIHandlerMojo, 40 class TestUIHandler
41 public shell::InterfaceFactory<TestUIHandlerMojo> { 41 : public TestUIHandlerMojo,
42 public service_manager::InterfaceFactory<TestUIHandlerMojo> {
42 public: 43 public:
43 TestUIHandler() {} 44 TestUIHandler() {}
44 ~TestUIHandler() override {} 45 ~TestUIHandler() override {}
45 46
46 // Returns true if "fin" has been received. 47 // Returns true if "fin" has been received.
47 bool IsFinReceived() { return fin_received_; } 48 bool IsFinReceived() { return fin_received_; }
48 49
49 // TestUIHandlerMojo overrides. 50 // TestUIHandlerMojo overrides.
50 void SetClientPage(TestPagePtr page) override { page_ = std::move(page); } 51 void SetClientPage(TestPagePtr page) override { page_ = std::move(page); }
51 void HandleJsMessage(const mojo::String& message) override { 52 void HandleJsMessage(const mojo::String& message) override {
52 if (message.get() == "syn") { 53 if (message.get() == "syn") {
53 // Received "syn" message from WebUI page, send "ack" as reply. 54 // Received "syn" message from WebUI page, send "ack" as reply.
54 DCHECK(!syn_received_); 55 DCHECK(!syn_received_);
55 DCHECK(!fin_received_); 56 DCHECK(!fin_received_);
56 syn_received_ = true; 57 syn_received_ = true;
57 NativeMessageResultMojoPtr result(NativeMessageResultMojo::New()); 58 NativeMessageResultMojoPtr result(NativeMessageResultMojo::New());
58 result->message = mojo::String::From("ack"); 59 result->message = mojo::String::From("ack");
59 page_->HandleNativeMessage(std::move(result)); 60 page_->HandleNativeMessage(std::move(result));
60 } else if (message.get() == "fin") { 61 } else if (message.get() == "fin") {
61 // Received "fin" from the WebUI page in response to "ack". 62 // Received "fin" from the WebUI page in response to "ack".
62 DCHECK(syn_received_); 63 DCHECK(syn_received_);
63 DCHECK(!fin_received_); 64 DCHECK(!fin_received_);
64 fin_received_ = true; 65 fin_received_ = true;
65 } else { 66 } else {
66 NOTREACHED(); 67 NOTREACHED();
67 } 68 }
68 } 69 }
69 70
70 private: 71 private:
71 // shell::InterfaceFactory overrides. 72 // service_manager::InterfaceFactory overrides.
72 void Create(const shell::Identity& remote_identity, 73 void Create(const service_manager::Identity& remote_identity,
73 mojo::InterfaceRequest<TestUIHandlerMojo> request) override { 74 mojo::InterfaceRequest<TestUIHandlerMojo> request) override {
74 bindings_.AddBinding(this, std::move(request)); 75 bindings_.AddBinding(this, std::move(request));
75 } 76 }
76 77
77 mojo::BindingSet<TestUIHandlerMojo> bindings_; 78 mojo::BindingSet<TestUIHandlerMojo> bindings_;
78 TestPagePtr page_ = nullptr; 79 TestPagePtr page_ = nullptr;
79 // |true| if "syn" has been received. 80 // |true| if "syn" has been received.
80 bool syn_received_ = false; 81 bool syn_received_ = false;
81 // |true| if "fin" has been received. 82 // |true| if "fin" has been received.
82 bool fin_received_ = false; 83 bool fin_received_ = false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); 159 web_state()->GetNavigationManager()->LoadURLWithParams(load_params);
159 160
160 // Wait until |TestUIHandler| receives "ack" message from WebUI page. 161 // Wait until |TestUIHandler| receives "ack" message from WebUI page.
161 base::test::ios::WaitUntilCondition(^{ 162 base::test::ios::WaitUntilCondition(^{
162 base::RunLoop().RunUntilIdle(); 163 base::RunLoop().RunUntilIdle();
163 return test_ui_handler()->IsFinReceived(); 164 return test_ui_handler()->IsFinReceived();
164 }); 165 });
165 } 166 }
166 167
167 } // namespace web 168 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/webui/mojo_facade_unittest.mm ('k') | mash/app_driver/app_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698