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

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

Issue 2037703004: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "base/values.h" 7 #include "base/values.h"
8 #include "extensions/browser/api/web_request/upload_data_presenter.h" 8 #include "extensions/browser/api/web_request/upload_data_presenter.h"
9 #include "extensions/browser/api/web_request/web_request_api_constants.h" 9 #include "extensions/browser/api/web_request/web_request_api_constants.h"
10 #include "net/base/upload_bytes_element_reader.h" 10 #include "net/base/upload_bytes_element_reader.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace keys = extension_web_request_api_constants; 13 namespace keys = extension_web_request_api_constants;
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 // This only tests the handling of dots in keys. Other functionality is covered 17 // This only tests the handling of dots in keys. Other functionality is covered
18 // by ExtensionWebRequestTest.AccessRequestBodyData and 18 // by ExtensionWebRequestTest.AccessRequestBodyData and
19 // WebRequestFormDataParserTest. 19 // WebRequestFormDataParserTest.
20 TEST(WebRequestUploadDataPresenterTest, ParsedData) { 20 TEST(WebRequestUploadDataPresenterTest, ParsedData) {
21 // Input. 21 // Input.
22 const char block[] = "key.with.dots=value"; 22 const char block[] = "key.with.dots=value";
23 net::UploadBytesElementReader element(block, sizeof(block) - 1); 23 net::UploadBytesElementReader element(block, sizeof(block) - 1);
24 24
25 // Expected output. 25 // Expected output.
26 std::unique_ptr<base::ListValue> values(new base::ListValue); 26 std::unique_ptr<base::ListValue> values(new base::ListValue);
27 values->Append(new base::StringValue("value")); 27 values->AppendString("value");
28 base::DictionaryValue expected_form; 28 base::DictionaryValue expected_form;
29 expected_form.SetWithoutPathExpansion("key.with.dots", values.release()); 29 expected_form.SetWithoutPathExpansion("key.with.dots", values.release());
30 30
31 // Real output. 31 // Real output.
32 std::unique_ptr<ParsedDataPresenter> parsed_data_presenter( 32 std::unique_ptr<ParsedDataPresenter> parsed_data_presenter(
33 ParsedDataPresenter::CreateForTests()); 33 ParsedDataPresenter::CreateForTests());
34 ASSERT_TRUE(parsed_data_presenter.get() != NULL); 34 ASSERT_TRUE(parsed_data_presenter.get() != NULL);
35 parsed_data_presenter->FeedNext(element); 35 parsed_data_presenter->FeedNext(element);
36 EXPECT_TRUE(parsed_data_presenter->Succeeded()); 36 EXPECT_TRUE(parsed_data_presenter->Succeeded());
37 std::unique_ptr<base::Value> result = parsed_data_presenter->Result(); 37 std::unique_ptr<base::Value> result = parsed_data_presenter->Result();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 raw_presenter.FeedNextFile(kFilename); 73 raw_presenter.FeedNextFile(kFilename);
74 raw_presenter.FeedNextBytes(block2, block2_size); 74 raw_presenter.FeedNextBytes(block2, block2_size);
75 EXPECT_TRUE(raw_presenter.Succeeded()); 75 EXPECT_TRUE(raw_presenter.Succeeded());
76 std::unique_ptr<base::Value> result = raw_presenter.Result(); 76 std::unique_ptr<base::Value> result = raw_presenter.Result();
77 ASSERT_TRUE(result.get() != NULL); 77 ASSERT_TRUE(result.get() != NULL);
78 78
79 EXPECT_TRUE(result->Equals(&expected_list)); 79 EXPECT_TRUE(result->Equals(&expected_list));
80 } 80 }
81 81
82 } // namespace extensions 82 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698