| Index: chrome/browser/extensions/api/web_request/upload_data_presenter_unittest.cc
|
| diff --git a/chrome/browser/extensions/api/web_request/upload_data_presenter_unittest.cc b/chrome/browser/extensions/api/web_request/upload_data_presenter_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..78eff8fc59a48c76a1e2d8691a594a96a43e7162
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/web_request/upload_data_presenter_unittest.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/extensions/api/web_request/upload_data_presenter.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +using base::BinaryValue;
|
| +using base::ListValue;
|
| +using base::StringValue;
|
| +using base::Value;
|
| +
|
| +namespace extensions {
|
| +
|
| +// ChunkedErrorPresenter is tested within
|
| +// ExtensionWebRequestTest.AccessRequestBodyData .
|
| +
|
| +// ParsedDataPresenter is tested on these places:
|
| +// * The underlying parser in WebRequestFormDataParserTest.
|
| +// * The extraction of data from URLRequest in
|
| +// ExtensionWebRequestTest.AccessRequestBodyData.
|
| +
|
| +TEST(WebRequestUploadDataPresenterTest, RawData) {
|
| + // Input.
|
| + char block_data1[] = "test";
|
| + std::vector<char> block1(block_data1, block_data1 + arraysize(block_data1));
|
| + const char kFilename[] = "path/test_filename.ext";
|
| + char block_data2[] = "another test";
|
| + std::vector<char> block2(block_data2, block_data2 + arraysize(block_data2));
|
| +
|
| + // Expected output.
|
| + scoped_ptr<BinaryValue> expected_a(
|
| + BinaryValue::CreateWithCopiedBuffer(&(block1[0]), block1.size()));
|
| + ASSERT_TRUE(expected_a.get() != NULL);
|
| + scoped_ptr<StringValue> expected_b(Value::CreateStringValue(kFilename));
|
| + ASSERT_TRUE(expected_b.get() != NULL);
|
| + scoped_ptr<BinaryValue> expected_c(
|
| + BinaryValue::CreateWithCopiedBuffer(&(block2[0]), block2.size()));
|
| + ASSERT_TRUE(expected_c.get() != NULL);
|
| +
|
| + ListValue expected_list;
|
| + expected_list.Append(expected_a.release());
|
| + expected_list.Append(expected_b.release());
|
| + expected_list.Append(expected_c.release());
|
| +
|
| + // Real output.
|
| + RawDataPresenter raw_presenter;
|
| + raw_presenter.FeedNextBytes(block1);
|
| + raw_presenter.FeedNextFile(kFilename);
|
| + raw_presenter.FeedNextBytes(block2);
|
| + EXPECT_TRUE(raw_presenter.Succeeded());
|
| + scoped_ptr<Value> result = raw_presenter.Result();
|
| +
|
| + EXPECT_TRUE(result->Equals(&expected_list));
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|