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

Unified Diff: webrtc/base/stream_unittest.cc

Issue 1245143005: Remove CircularFileStream / replace it with CallSessionFileRotatingStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add GetSize to FileRotatingStream Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/stream.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/stream_unittest.cc
diff --git a/webrtc/base/stream_unittest.cc b/webrtc/base/stream_unittest.cc
index 4d5066ab55fce576d2be82df4c4eef937511d147..4172a9726c8bec8939242f20fbc99b0cd1be7140 100644
--- a/webrtc/base/stream_unittest.cc
+++ b/webrtc/base/stream_unittest.cc
@@ -372,162 +372,4 @@ TEST(FifoBufferTest, WriteOffsetAndReadOffset) {
EXPECT_EQ(SR_BLOCK, buf.ReadOffset(out, 10, 16, NULL));
}
-class CircularFileStreamTest : public ::testing::Test {
- protected:
- static size_t const kMaxSize = 12;
-
- CircularFileStreamTest() : is_open_(false), stream_(kMaxSize) {
- Pathname temp_dir;
- if (Filesystem::GetAppTempFolder(&temp_dir)) {
- logfile_name_ =
- Filesystem::TempFilename(temp_dir, "CircularFileStreamTest");
- }
- }
-
- virtual void SetUp() {
- int error = -1;
- is_open_ = stream_.Open(logfile_name_, "wb", &error);
- }
-
- virtual void TearDown() {
- if (!Filesystem::IsAbsent(logfile_name_)) {
- Filesystem::DeleteFile(logfile_name_);
- }
- }
-
- bool is_open_;
- CircularFileStream stream_;
- std::string logfile_name_;
-};
-
-TEST_F(CircularFileStreamTest, ReadWriteWithinCapacity) {
- EXPECT_TRUE(is_open_);
- // Write contents.
- const uint8_t bytes[] = {1, 2, 3, 4, 5, 6};
- size_t written = 0;
- int error = 0;
- EXPECT_EQ(SR_SUCCESS, stream_.Write(bytes, sizeof(bytes), &written, &error));
- EXPECT_EQ(0, error);
- EXPECT_EQ(written, sizeof(bytes));
- stream_.Close();
-
- // Check file contents.
- uint8_t content_bytes[sizeof(bytes)] = {};
- scoped_ptr<FileStream> content_stream(
- Filesystem::OpenFile(logfile_name_, "r"));
- size_t num_content_bytes_read = 0;
- EXPECT_TRUE(content_stream);
- error = 0;
- EXPECT_EQ(SR_SUCCESS,
- content_stream->Read(content_bytes, sizeof(content_bytes),
- &num_content_bytes_read, &error));
- EXPECT_EQ(sizeof(content_bytes), num_content_bytes_read);
- ASSERT_EQ(sizeof(content_bytes), sizeof(bytes));
- EXPECT_EQ(0, memcmp(content_bytes, bytes, sizeof(content_bytes)));
-
- // Check read result.
- error = 0;
- size_t file_size = 0;
- EXPECT_TRUE(stream_.Open(logfile_name_, "r", &error));
- EXPECT_TRUE(stream_.GetSize(&file_size));
- EXPECT_EQ(0, error);
- EXPECT_EQ(sizeof(bytes), file_size);
- scoped_ptr<uint8_t[]> read_bytes(new uint8_t[file_size]);
- size_t num_read_bytes = 0;
- error = 0;
- EXPECT_EQ(SR_SUCCESS, stream_.ReadAll(read_bytes.get(), file_size,
- &num_read_bytes, &error));
- EXPECT_EQ(sizeof(bytes), num_read_bytes);
- EXPECT_EQ(0, memcmp(bytes, read_bytes.get(), file_size));
-}
-
-TEST_F(CircularFileStreamTest, ReadWriteAtCapacity) {
- EXPECT_TRUE(is_open_);
- // Write contents.
- const uint8_t bytes[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
- size_t written = 0;
- int error = 0;
- EXPECT_EQ(SR_SUCCESS, stream_.Write(bytes, sizeof(bytes), &written, &error));
- EXPECT_EQ(0, error);
- EXPECT_EQ(written, sizeof(bytes));
- stream_.Close();
-
- // Check file contents.
- uint8_t content_bytes[sizeof(bytes)] = {};
- scoped_ptr<FileStream> content_stream(
- Filesystem::OpenFile(logfile_name_, "r"));
- size_t num_content_bytes_read = 0;
- EXPECT_TRUE(content_stream);
- error = 0;
- EXPECT_EQ(SR_SUCCESS,
- content_stream->Read(content_bytes, sizeof(content_bytes),
- &num_content_bytes_read, &error));
- EXPECT_EQ(sizeof(content_bytes), num_content_bytes_read);
- ASSERT_EQ(sizeof(content_bytes), sizeof(bytes));
- EXPECT_EQ(0, memcmp(content_bytes, bytes, sizeof(content_bytes)));
-
- // Check read result.
- error = 0;
- size_t file_size = 0;
- EXPECT_TRUE(stream_.Open(logfile_name_, "r", &error));
- EXPECT_TRUE(stream_.GetSize(&file_size));
- EXPECT_EQ(0, error);
- EXPECT_EQ(sizeof(bytes), file_size);
- scoped_ptr<uint8_t[]> read_bytes(new uint8_t[file_size]);
- size_t num_read_bytes = 0;
- error = 0;
- EXPECT_EQ(SR_SUCCESS, stream_.ReadAll(read_bytes.get(), file_size,
- &num_read_bytes, &error));
- EXPECT_EQ(sizeof(bytes), num_read_bytes);
- EXPECT_EQ(0, memcmp(bytes, read_bytes.get(), file_size));
-}
-
-TEST_F(CircularFileStreamTest, ReadWriteOverCapacity) {
- EXPECT_TRUE(is_open_);
- // Write contents.
- const uint8_t bytes[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
- size_t written = 0;
- int error = 0;
- EXPECT_EQ(SR_SUCCESS,
- stream_.WriteAll(bytes, sizeof(bytes), &written, &error));
- EXPECT_EQ(0, error);
- EXPECT_EQ(written, sizeof(bytes));
- stream_.Close();
-
- // Check file contents.
- uint8_t content_bytes[kMaxSize] = {};
- scoped_ptr<FileStream> content_stream(
- Filesystem::OpenFile(logfile_name_, "r"));
- size_t num_content_bytes_read = 0;
- EXPECT_TRUE(content_stream);
- error = 0;
- EXPECT_EQ(SR_SUCCESS,
- content_stream->Read(content_bytes, sizeof(content_bytes),
- &num_content_bytes_read, &error));
- EXPECT_EQ(sizeof(content_bytes), num_content_bytes_read);
- const uint8_t expected_content_bytes[] = {
- 1, 2, 3, 4, 5, 6, 13, 14, 15, 10, 11, 12};
- ASSERT_EQ(sizeof(content_bytes), sizeof(expected_content_bytes));
- EXPECT_EQ(
- 0, memcmp(expected_content_bytes, content_bytes, sizeof(content_bytes)));
-
- // Check read result.
- error = 0;
- size_t file_size = 0;
- EXPECT_TRUE(stream_.Open(logfile_name_, "r", &error));
- EXPECT_TRUE(stream_.GetSize(&file_size));
- EXPECT_EQ(0, error);
- EXPECT_EQ(sizeof(content_bytes), file_size);
- scoped_ptr<uint8_t[]> read_bytes(new uint8_t[file_size]);
- size_t num_read_bytes = 0;
- error = 0;
- EXPECT_EQ(SR_SUCCESS, stream_.ReadAll(read_bytes.get(), file_size,
- &num_read_bytes, &error));
-
- const uint8_t expected_read_bytes[] = {
- 1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15};
- EXPECT_EQ(sizeof(expected_read_bytes), num_read_bytes);
- EXPECT_EQ(0, memcmp(expected_read_bytes, read_bytes.get(), file_size));
-}
-
} // namespace rtc
« no previous file with comments | « webrtc/base/stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698