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

Side by Side Diff: mojo/fetcher/data_fetcher_unittest.cc

Issue 1552983003: Fix a bunch of mojo_public_*_unittests with the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 11 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 | « no previous file | mojo/message_pump/message_pump_mojo_unittest.cc » ('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/fetcher/data_fetcher.h" 5 #include "mojo/fetcher/data_fetcher.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_EQ(expected_status_code, response->status_code); 75 EXPECT_EQ(expected_status_code, response->status_code);
76 76
77 if (expected_status_code != 200) 77 if (expected_status_code != 200)
78 return; 78 return;
79 79
80 ASSERT_TRUE(response->body.is_valid()); 80 ASSERT_TRUE(response->body.is_valid());
81 EXPECT_EQ(expected_mime_type, response->mime_type); 81 EXPECT_EQ(expected_mime_type, response->mime_type);
82 82
83 uint32_t num_bytes = 0; 83 uint32_t num_bytes = 0;
84 Handle body_handle = response->body.release(); 84 Handle body_handle = response->body.release();
85
86 MojoHandleSignalsState hss;
87 ASSERT_EQ(MOJO_RESULT_OK,
88 MojoWait(body_handle.value(), MOJO_HANDLE_SIGNAL_READABLE,
89 MOJO_DEADLINE_INDEFINITE, &hss));
90
85 MojoResult result = MojoReadData(body_handle.value(), nullptr, &num_bytes, 91 MojoResult result = MojoReadData(body_handle.value(), nullptr, &num_bytes,
86 MOJO_READ_DATA_FLAG_QUERY); 92 MOJO_READ_DATA_FLAG_QUERY);
87 ASSERT_EQ(MOJO_RESULT_OK, result); 93 ASSERT_EQ(MOJO_RESULT_OK, result);
88 94
89 scoped_ptr<char[]> body(new char[num_bytes]); 95 scoped_ptr<char[]> body(new char[num_bytes]);
90 result = MojoReadData(body_handle.value(), body.get(), &num_bytes, 96 result = MojoReadData(body_handle.value(), body.get(), &num_bytes,
91 MOJO_READ_DATA_FLAG_ALL_OR_NONE); 97 MOJO_READ_DATA_FLAG_ALL_OR_NONE);
92 ASSERT_EQ(MOJO_RESULT_OK, result); 98 ASSERT_EQ(MOJO_RESULT_OK, result);
93 EXPECT_EQ(expected_body, std::string(body.get(), num_bytes)); 99 EXPECT_EQ(expected_body, std::string(body.get(), num_bytes));
94 } 100 }
95 101
96 private: 102 private:
97 base::MessageLoop loop_; 103 base::MessageLoop loop_;
98 104
99 DISALLOW_COPY_AND_ASSIGN(DataFetcherTest); 105 DISALLOW_COPY_AND_ASSIGN(DataFetcherTest);
100 }; 106 };
101 107
102 TEST_F(DataFetcherTest, BasicSuccess) { 108 TEST_F(DataFetcherTest, BasicSuccess) {
103 TestFetchURL("data:text/html,Hello world", 200, "text/html", "Hello world"); 109 TestFetchURL("data:text/html,Hello world", 200, "text/html", "Hello world");
104 } 110 }
105 111
106 TEST_F(DataFetcherTest, BasicFailure) { 112 TEST_F(DataFetcherTest, BasicFailure) {
107 TestFetchURL("about:blank", 400, std::string(), std::string()); 113 TestFetchURL("about:blank", 400, std::string(), std::string());
108 TestFetchURL("data:;base64,aGVs_-_-", 400, std::string(), std::string()); 114 TestFetchURL("data:;base64,aGVs_-_-", 400, std::string(), std::string());
109 } 115 }
110 116
111 } // namespace 117 } // namespace
112 } // namespace fetcher 118 } // namespace fetcher
113 } // namespace mojo 119 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698