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 <cstdlib> | 5 #include <cstdlib> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/base/data_buffer.h" | 10 #include "media/base/data_buffer.h" |
11 #include "media/base/seekable_buffer.h" | 11 #include "media/base/seekable_buffer.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
16 class SeekableBufferTest : public testing::Test { | 16 class SeekableBufferTest : public testing::Test { |
17 public: | 17 public: |
18 SeekableBufferTest() : buffer_(kBufferSize, kBufferSize) { | 18 SeekableBufferTest() : buffer_(kBufferSize, kBufferSize) { |
19 } | 19 } |
20 | 20 |
21 protected: | 21 protected: |
22 static const int kDataSize = 409600; | 22 static const int kDataSize = 409600; |
23 static const int kBufferSize = 4096; | 23 static const int kBufferSize = 4096; |
24 static const int kWriteSize = 512; | 24 static const int kWriteSize = 512; |
25 | 25 |
26 virtual void SetUp() { | 26 void SetUp() override { |
27 // Note: We use srand() and rand() rather than base::RandXXX() to improve | 27 // Note: We use srand() and rand() rather than base::RandXXX() to improve |
28 // unit test performance. We don't need good random numbers, just | 28 // unit test performance. We don't need good random numbers, just |
29 // something that generates "mixed data." | 29 // something that generates "mixed data." |
30 const unsigned int kKnownSeed = 0x98765432; | 30 const unsigned int kKnownSeed = 0x98765432; |
31 srand(kKnownSeed); | 31 srand(kKnownSeed); |
32 | 32 |
33 // Create random test data samples. | 33 // Create random test data samples. |
34 for (int i = 0; i < kDataSize; i++) | 34 for (int i = 0; i < kDataSize; i++) |
35 data_[i] = static_cast<char>(rand()); | 35 data_[i] = static_cast<char>(rand()); |
36 } | 36 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" | 346 EXPECT_EQ(tests[i].expected_time, actual) << "With test = { start:" |
347 << tests[i].first_time_useconds << ", duration:" | 347 << tests[i].first_time_useconds << ", duration:" |
348 << tests[i].duration_useconds << ", consumed:" | 348 << tests[i].duration_useconds << ", consumed:" |
349 << tests[i].consume_bytes << " }\n"; | 349 << tests[i].consume_bytes << " }\n"; |
350 | 350 |
351 buffer_.Clear(); | 351 buffer_.Clear(); |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 } // namespace media | 355 } // namespace media |
OLD | NEW |