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

Side by Side Diff: extensions/browser/api/web_request/upload_data_presenter_unittest.cc

Issue 2065793002: Return a unique_ptr from BinaryValue::CreateWithCopiedBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android and CrOS Created 4 years, 6 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
OLDNEW
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>
8
7 #include "base/values.h" 9 #include "base/values.h"
8 #include "extensions/browser/api/web_request/upload_data_presenter.h" 10 #include "extensions/browser/api/web_request/upload_data_presenter.h"
9 #include "extensions/browser/api/web_request/web_request_api_constants.h" 11 #include "extensions/browser/api/web_request/web_request_api_constants.h"
10 #include "net/base/upload_bytes_element_reader.h" 12 #include "net/base/upload_bytes_element_reader.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 namespace keys = extension_web_request_api_constants; 15 namespace keys = extension_web_request_api_constants;
14 16
15 namespace extensions { 17 namespace extensions {
16 18
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 52
51 // Expected output. 53 // Expected output.
52 std::unique_ptr<base::BinaryValue> expected_a( 54 std::unique_ptr<base::BinaryValue> expected_a(
53 base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size)); 55 base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size));
54 ASSERT_TRUE(expected_a.get() != NULL); 56 ASSERT_TRUE(expected_a.get() != NULL);
55 std::unique_ptr<base::StringValue> expected_b( 57 std::unique_ptr<base::StringValue> expected_b(
56 new base::StringValue(kFilename)); 58 new base::StringValue(kFilename));
57 ASSERT_TRUE(expected_b.get() != NULL); 59 ASSERT_TRUE(expected_b.get() != NULL);
58 std::unique_ptr<base::BinaryValue> expected_c( 60 std::unique_ptr<base::BinaryValue> expected_c(
59 base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size)); 61 base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size));
60 ASSERT_TRUE(expected_c.get() != NULL); 62 ASSERT_TRUE(expected_c.get() != NULL);
dcheng 2016/06/15 08:34:03 These asserts don't really seem useful but meh. If
61 63
62 base::ListValue expected_list; 64 base::ListValue expected_list;
63 subtle::AppendKeyValuePair( 65 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey,
64 keys::kRequestBodyRawBytesKey, expected_a.release(), &expected_list); 66 std::move(expected_a), &expected_list);
65 subtle::AppendKeyValuePair( 67 subtle::AppendKeyValuePair(keys::kRequestBodyRawFileKey,
66 keys::kRequestBodyRawFileKey, expected_b.release(), &expected_list); 68 std::move(expected_b), &expected_list);
67 subtle::AppendKeyValuePair( 69 subtle::AppendKeyValuePair(keys::kRequestBodyRawBytesKey,
68 keys::kRequestBodyRawBytesKey, expected_c.release(), &expected_list); 70 std::move(expected_c), &expected_list);
69 71
70 // Real output. 72 // Real output.
71 RawDataPresenter raw_presenter; 73 RawDataPresenter raw_presenter;
72 raw_presenter.FeedNextBytes(block1, block1_size); 74 raw_presenter.FeedNextBytes(block1, block1_size);
73 raw_presenter.FeedNextFile(kFilename); 75 raw_presenter.FeedNextFile(kFilename);
74 raw_presenter.FeedNextBytes(block2, block2_size); 76 raw_presenter.FeedNextBytes(block2, block2_size);
75 EXPECT_TRUE(raw_presenter.Succeeded()); 77 EXPECT_TRUE(raw_presenter.Succeeded());
76 std::unique_ptr<base::Value> result = raw_presenter.Result(); 78 std::unique_ptr<base::Value> result = raw_presenter.Result();
77 ASSERT_TRUE(result.get() != NULL); 79 ASSERT_TRUE(result.get() != NULL);
78 80
79 EXPECT_TRUE(result->Equals(&expected_list)); 81 EXPECT_TRUE(result->Equals(&expected_list));
80 } 82 }
81 83
82 } // namespace extensions 84 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698