OLD | NEW |
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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 data_pipe_handle, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE); | 120 data_pipe_handle, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE); |
121 EXPECT_EQ(MOJO_RESULT_OK, result); | 121 EXPECT_EQ(MOJO_RESULT_OK, result); |
122 EXPECT_EQ(64u, buffer_size); | 122 EXPECT_EQ(64u, buffer_size); |
123 for (int i = 0; i < 64; ++i) { | 123 for (int i = 0; i < 64; ++i) { |
124 EXPECT_EQ(i, buffer[i]); | 124 EXPECT_EQ(i, buffer[i]); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 void CheckCorruptedString(const mojo::String& arg) { | 128 void CheckCorruptedString(const mojo::String& arg) { |
129 // The values don't matter so long as all accesses are within bounds. | 129 // The values don't matter so long as all accesses are within bounds. |
130 std::string name = arg.To<std::string>(); | 130 if (arg.is_null()) |
131 for (size_t i = 0; i < name.length(); ++i) | 131 return; |
132 g_waste_accumulator += name[i]; | 132 for (size_t i = 0; i < arg.size(); ++i) |
| 133 g_waste_accumulator += arg[i]; |
133 } | 134 } |
134 | 135 |
135 void CheckCorruptedStringArray(const mojo::Array<mojo::String>& string_array) { | 136 void CheckCorruptedStringArray(const mojo::Array<mojo::String>& string_array) { |
| 137 if (string_array.is_null()) |
| 138 return; |
136 for (size_t i = 0; i < string_array.size(); ++i) | 139 for (size_t i = 0; i < string_array.size(); ++i) |
137 CheckCorruptedString(string_array[i]); | 140 CheckCorruptedString(string_array[i]); |
138 } | 141 } |
139 | 142 |
140 // Base Provider implementation class. It's expected that tests subclass and | 143 // Base Provider implementation class. It's expected that tests subclass and |
141 // override the appropriate Provider functions. When test is done quit the | 144 // override the appropriate Provider functions. When test is done quit the |
142 // run_loop(). | 145 // run_loop(). |
143 class CppSideConnection : public js_to_cpp::CppSide { | 146 class CppSideConnection : public js_to_cpp::CppSide { |
144 public: | 147 public: |
145 CppSideConnection() : run_loop_(NULL), js_side_(NULL) { | 148 CppSideConnection() : run_loop_(NULL), js_side_(NULL) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (IsRunningOnIsolatedBot()) | 346 if (IsRunningOnIsolatedBot()) |
344 return; | 347 return; |
345 | 348 |
346 BitFlipCppSideConnection cpp_side_connection; | 349 BitFlipCppSideConnection cpp_side_connection; |
347 RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection); | 350 RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection); |
348 EXPECT_TRUE(cpp_side_connection.DidSucceed()); | 351 EXPECT_TRUE(cpp_side_connection.DidSucceed()); |
349 } | 352 } |
350 | 353 |
351 } // namespace js | 354 } // namespace js |
352 } // namespace mojo | 355 } // namespace mojo |
OLD | NEW |