| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "extensions/browser/api/web_request/upload_data_presenter.h" | 10 #include "extensions/browser/api/web_request/upload_data_presenter.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const char block1[] = "test"; | 47 const char block1[] = "test"; |
| 48 const size_t block1_size = sizeof(block1) - 1; | 48 const size_t block1_size = sizeof(block1) - 1; |
| 49 const char kFilename[] = "path/test_filename.ext"; | 49 const char kFilename[] = "path/test_filename.ext"; |
| 50 const char block2[] = "another test"; | 50 const char block2[] = "another test"; |
| 51 const size_t block2_size = sizeof(block2) - 1; | 51 const size_t block2_size = sizeof(block2) - 1; |
| 52 | 52 |
| 53 // Expected output. | 53 // Expected output. |
| 54 std::unique_ptr<base::BinaryValue> expected_a( | 54 std::unique_ptr<base::BinaryValue> expected_a( |
| 55 base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size)); | 55 base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size)); |
| 56 ASSERT_TRUE(expected_a.get() != NULL); | 56 ASSERT_TRUE(expected_a.get() != NULL); |
| 57 std::unique_ptr<base::StringValue> expected_b( | 57 std::unique_ptr<base::Value> expected_b(new base::Value(kFilename)); |
| 58 new base::StringValue(kFilename)); | |
| 59 ASSERT_TRUE(expected_b.get() != NULL); | 58 ASSERT_TRUE(expected_b.get() != NULL); |
| 60 std::unique_ptr<base::BinaryValue> expected_c( | 59 std::unique_ptr<base::BinaryValue> expected_c( |
| 61 base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size)); | 60 base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size)); |
| 62 ASSERT_TRUE(expected_c.get() != NULL); | 61 ASSERT_TRUE(expected_c.get() != NULL); |
| 63 | 62 |
| 64 base::ListValue expected_list; | 63 base::ListValue expected_list; |
| 65 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, | 64 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, |
| 66 std::move(expected_a), &expected_list); | 65 std::move(expected_a), &expected_list); |
| 67 subtle::AppendKeyValuePair(keys::kRequestBodyRawFileKey, | 66 subtle::AppendKeyValuePair(keys::kRequestBodyRawFileKey, |
| 68 std::move(expected_b), &expected_list); | 67 std::move(expected_b), &expected_list); |
| 69 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, | 68 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, |
| 70 std::move(expected_c), &expected_list); | 69 std::move(expected_c), &expected_list); |
| 71 | 70 |
| 72 // Real output. | 71 // Real output. |
| 73 RawDataPresenter raw_presenter; | 72 RawDataPresenter raw_presenter; |
| 74 raw_presenter.FeedNextBytes(block1, block1_size); | 73 raw_presenter.FeedNextBytes(block1, block1_size); |
| 75 raw_presenter.FeedNextFile(kFilename); | 74 raw_presenter.FeedNextFile(kFilename); |
| 76 raw_presenter.FeedNextBytes(block2, block2_size); | 75 raw_presenter.FeedNextBytes(block2, block2_size); |
| 77 EXPECT_TRUE(raw_presenter.Succeeded()); | 76 EXPECT_TRUE(raw_presenter.Succeeded()); |
| 78 std::unique_ptr<base::Value> result = raw_presenter.Result(); | 77 std::unique_ptr<base::Value> result = raw_presenter.Result(); |
| 79 ASSERT_TRUE(result.get() != NULL); | 78 ASSERT_TRUE(result.get() != NULL); |
| 80 | 79 |
| 81 EXPECT_TRUE(result->Equals(&expected_list)); | 80 EXPECT_TRUE(result->Equals(&expected_list)); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace extensions | 83 } // namespace extensions |
| OLD | NEW |