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

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

Issue 2496733002: Mojo C++ bindings: switch ios/web mojom targets to use STL types. (Closed)
Patch Set: Created 4 years, 1 month 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/test/BUILD.gn ('k') | no next file » | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 public service_manager::InterfaceFactory<TestUIHandlerMojo> { 42 public service_manager::InterfaceFactory<TestUIHandlerMojo> {
43 public: 43 public:
44 TestUIHandler() {} 44 TestUIHandler() {}
45 ~TestUIHandler() override {} 45 ~TestUIHandler() override {}
46 46
47 // Returns true if "fin" has been received. 47 // Returns true if "fin" has been received.
48 bool IsFinReceived() { return fin_received_; } 48 bool IsFinReceived() { return fin_received_; }
49 49
50 // TestUIHandlerMojo overrides. 50 // TestUIHandlerMojo overrides.
51 void SetClientPage(TestPagePtr page) override { page_ = std::move(page); } 51 void SetClientPage(TestPagePtr page) override { page_ = std::move(page); }
52 void HandleJsMessage(const mojo::String& message) override { 52 void HandleJsMessage(const std::string& message) override {
53 if (message.get() == "syn") { 53 if (message == "syn") {
54 // Received "syn" message from WebUI page, send "ack" as reply. 54 // Received "syn" message from WebUI page, send "ack" as reply.
55 DCHECK(!syn_received_); 55 DCHECK(!syn_received_);
56 DCHECK(!fin_received_); 56 DCHECK(!fin_received_);
57 syn_received_ = true; 57 syn_received_ = true;
58 NativeMessageResultMojoPtr result(NativeMessageResultMojo::New()); 58 NativeMessageResultMojoPtr result(NativeMessageResultMojo::New());
59 result->message = mojo::String::From("ack"); 59 result->message = "ack";
60 page_->HandleNativeMessage(std::move(result)); 60 page_->HandleNativeMessage(std::move(result));
61 } else if (message.get() == "fin") { 61 } else if (message == "fin") {
62 // Received "fin" from the WebUI page in response to "ack". 62 // Received "fin" from the WebUI page in response to "ack".
63 DCHECK(syn_received_); 63 DCHECK(syn_received_);
64 DCHECK(!fin_received_); 64 DCHECK(!fin_received_);
65 fin_received_ = true; 65 fin_received_ = true;
66 } else { 66 } else {
67 NOTREACHED(); 67 NOTREACHED();
68 } 68 }
69 } 69 }
70 70
71 private: 71 private:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); 159 web_state()->GetNavigationManager()->LoadURLWithParams(load_params);
160 160
161 // Wait until |TestUIHandler| receives "ack" message from WebUI page. 161 // Wait until |TestUIHandler| receives "ack" message from WebUI page.
162 base::test::ios::WaitUntilCondition(^{ 162 base::test::ios::WaitUntilCondition(^{
163 base::RunLoop().RunUntilIdle(); 163 base::RunLoop().RunUntilIdle();
164 return test_ui_handler()->IsFinReceived(); 164 return test_ui_handler()->IsFinReceived();
165 }); 165 });
166 } 166 }
167 167
168 } // namespace web 168 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698