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

Side by Side Diff: media/audio/simple_sources_unittest.cc

Issue 6628020: Cleaning up src/media to be consistent with static versus anonymous namespaces. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix namespaces Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/audio/audio_manager.h" 9 #include "media/audio/audio_manager.h"
10 #include "media/audio/fake_audio_output_stream.h" 10 #include "media/audio/fake_audio_output_stream.h"
11 #include "media/audio/simple_sources.h" 11 #include "media/audio/simple_sources.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 static void GenerateRandomData(char* buffer, uint32 len) {
15
16 void GenerateRandomData(char* buffer, uint32 len) {
17 static bool called = false; 15 static bool called = false;
18 if (!called) { 16 if (!called) {
19 called = true; 17 called = true;
20 int seed = static_cast<int>(base::Time::Now().ToInternalValue()); 18 int seed = static_cast<int>(base::Time::Now().ToInternalValue());
21 srand(seed); 19 srand(seed);
22 VLOG(1) << "Random seed: " << seed; 20 VLOG(1) << "Random seed: " << seed;
23 } 21 }
24 22
25 for (uint32 i = 0; i < len; i++) 23 for (uint32 i = 0; i < len; i++)
26 buffer[i] = static_cast<char>(rand()); 24 buffer[i] = static_cast<char>(rand());
27 } 25 }
28 26
29 } // namespace
30
31 // To test write size smaller than read size. 27 // To test write size smaller than read size.
32 TEST(SimpleSourcesTest, PushSourceSmallerWrite) { 28 TEST(SimpleSourcesTest, PushSourceSmallerWrite) {
33 const uint32 kDataSize = 40960; 29 const uint32 kDataSize = 40960;
34 scoped_array<char> data(new char[kDataSize]); 30 scoped_array<char> data(new char[kDataSize]);
35 GenerateRandomData(data.get(), kDataSize); 31 GenerateRandomData(data.get(), kDataSize);
36 32
37 // Choose two prime numbers for read and write sizes. 33 // Choose two prime numbers for read and write sizes.
38 const uint32 kWriteSize = 283; 34 const uint32 kWriteSize = 283;
39 const uint32 kReadSize = 293; 35 const uint32 kReadSize = 293;
40 scoped_array<uint8> read_data(new uint8[kReadSize]); 36 scoped_array<uint8> read_data(new uint8[kReadSize]);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 EXPECT_EQ(0, last_buffer[0]); 93 EXPECT_EQ(0, last_buffer[0]);
98 EXPECT_EQ(5126, last_buffer[1]); 94 EXPECT_EQ(5126, last_buffer[1]);
99 EXPECT_TRUE(last_buffer[1] < last_buffer[2]); 95 EXPECT_TRUE(last_buffer[1] < last_buffer[2]);
100 EXPECT_TRUE(last_buffer[2] < last_buffer[3]); 96 EXPECT_TRUE(last_buffer[2] < last_buffer[3]);
101 // Spot test negative incursion of sine wave. 97 // Spot test negative incursion of sine wave.
102 EXPECT_EQ(0, last_buffer[half_period]); 98 EXPECT_EQ(0, last_buffer[half_period]);
103 EXPECT_EQ(-5126, last_buffer[half_period + 1]); 99 EXPECT_EQ(-5126, last_buffer[half_period + 1]);
104 EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]); 100 EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]);
105 EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]); 101 EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]);
106 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698