OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 protected: | 149 protected: |
150 std::string FormatMessage(const std::string& message) { | 150 std::string FormatMessage(const std::string& message) { |
151 Pickle pickle; | 151 Pickle pickle; |
152 pickle.WriteString(message); | 152 pickle.WriteString(message); |
153 return std::string(const_cast<const Pickle*>(&pickle)->payload(), | 153 return std::string(const_cast<const Pickle*>(&pickle)->payload(), |
154 pickle.payload_size()); | 154 pickle.payload_size()); |
155 } | 155 } |
156 | 156 |
157 base::FilePath CreateTempFileWithMessage(const std::string& message) { | 157 base::FilePath CreateTempFileWithMessage(const std::string& message) { |
158 base::FilePath filename = temp_dir_.path().AppendASCII("input"); | 158 base::FilePath filename = temp_dir_.path().AppendASCII("input"); |
159 file_util::CreateTemporaryFile(&filename); | 159 base::CreateTemporaryFile(&filename); |
160 std::string message_with_header = FormatMessage(message); | 160 std::string message_with_header = FormatMessage(message); |
161 EXPECT_TRUE(file_util::WriteFile( | 161 EXPECT_TRUE(file_util::WriteFile( |
162 filename, message_with_header.data(), message_with_header.size())); | 162 filename, message_with_header.data(), message_with_header.size())); |
163 return filename; | 163 return filename; |
164 } | 164 } |
165 | 165 |
166 // Force the channel to be dev. | 166 // Force the channel to be dev. |
167 base::ScopedTempDir temp_dir_; | 167 base::ScopedTempDir temp_dir_; |
168 ScopedCurrentChannel current_channel_; | 168 ScopedCurrentChannel current_channel_; |
169 scoped_ptr<NativeMessageProcessHost> native_message_process_host_; | 169 scoped_ptr<NativeMessageProcessHost> native_message_process_host_; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 read_message_run_loop_->Run(); | 291 read_message_run_loop_->Run(); |
292 EXPECT_TRUE(last_message_parsed_->GetInteger("id", &id)); | 292 EXPECT_TRUE(last_message_parsed_->GetInteger("id", &id)); |
293 EXPECT_EQ(2, id); | 293 EXPECT_EQ(2, id); |
294 EXPECT_TRUE(last_message_parsed_->GetString("echo.foo", &text)); | 294 EXPECT_TRUE(last_message_parsed_->GetString("echo.foo", &text)); |
295 EXPECT_EQ("bar", text); | 295 EXPECT_EQ("bar", text); |
296 EXPECT_TRUE(last_message_parsed_->GetString("caller_url", &url)); | 296 EXPECT_TRUE(last_message_parsed_->GetString("caller_url", &url)); |
297 EXPECT_EQ(expected_url, url); | 297 EXPECT_EQ(expected_url, url); |
298 } | 298 } |
299 | 299 |
300 } // namespace extensions | 300 } // namespace extensions |
OLD | NEW |