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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 TEST(WebRequestUploadDataPresenterTest, RawData) { | 45 TEST(WebRequestUploadDataPresenterTest, RawData) { |
46 // Input. | 46 // Input. |
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::Value> expected_a( |
55 base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size)); | 55 base::Value::CreateWithCopiedBuffer(block1, block1_size)); |
56 ASSERT_TRUE(expected_a.get() != NULL); | 56 ASSERT_TRUE(expected_a.get() != NULL); |
57 std::unique_ptr<base::Value> expected_b(new base::Value(kFilename)); | 57 std::unique_ptr<base::Value> expected_b(new base::Value(kFilename)); |
58 ASSERT_TRUE(expected_b.get() != NULL); | 58 ASSERT_TRUE(expected_b.get() != NULL); |
59 std::unique_ptr<base::BinaryValue> expected_c( | 59 std::unique_ptr<base::Value> expected_c( |
60 base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size)); | 60 base::Value::CreateWithCopiedBuffer(block2, block2_size)); |
61 ASSERT_TRUE(expected_c.get() != NULL); | 61 ASSERT_TRUE(expected_c.get() != NULL); |
62 | 62 |
63 base::ListValue expected_list; | 63 base::ListValue expected_list; |
64 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, | 64 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, |
65 std::move(expected_a), &expected_list); | 65 std::move(expected_a), &expected_list); |
66 subtle::AppendKeyValuePair(keys::kRequestBodyRawFileKey, | 66 subtle::AppendKeyValuePair(keys::kRequestBodyRawFileKey, |
67 std::move(expected_b), &expected_list); | 67 std::move(expected_b), &expected_list); |
68 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, | 68 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey, |
69 std::move(expected_c), &expected_list); | 69 std::move(expected_c), &expected_list); |
70 | 70 |
71 // Real output. | 71 // Real output. |
72 RawDataPresenter raw_presenter; | 72 RawDataPresenter raw_presenter; |
73 raw_presenter.FeedNextBytes(block1, block1_size); | 73 raw_presenter.FeedNextBytes(block1, block1_size); |
74 raw_presenter.FeedNextFile(kFilename); | 74 raw_presenter.FeedNextFile(kFilename); |
75 raw_presenter.FeedNextBytes(block2, block2_size); | 75 raw_presenter.FeedNextBytes(block2, block2_size); |
76 EXPECT_TRUE(raw_presenter.Succeeded()); | 76 EXPECT_TRUE(raw_presenter.Succeeded()); |
77 std::unique_ptr<base::Value> result = raw_presenter.Result(); | 77 std::unique_ptr<base::Value> result = raw_presenter.Result(); |
78 ASSERT_TRUE(result.get() != NULL); | 78 ASSERT_TRUE(result.get() != NULL); |
79 | 79 |
80 EXPECT_TRUE(result->Equals(&expected_list)); | 80 EXPECT_TRUE(result->Equals(&expected_list)); |
81 } | 81 } |
82 | 82 |
83 } // namespace extensions | 83 } // namespace extensions |
OLD | NEW |