OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
9 #include "base/time/tick_clock.h" | 9 #include "base/time/tick_clock.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/cast/logging/logging_defines.h" | 11 #include "media/cast/logging/logging_defines.h" |
12 #include "media/cast/logging/logging_impl.h" | 12 #include "media/cast/logging/logging_impl.h" |
13 #include "media/cast/logging/simple_event_subscriber.h" | 13 #include "media/cast/logging/simple_event_subscriber.h" |
14 #include "media/cast/test/fake_single_thread_task_runner.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 | 15 |
17 namespace media { | 16 namespace media { |
18 namespace cast { | 17 namespace cast { |
19 | 18 |
20 // Insert frame duration- one second. | 19 // Insert frame duration- one second. |
21 const int64 kIntervalTime1S = 1; | 20 const int64 kIntervalTime1S = 1; |
22 // Test frame rate goal - 30fps. | 21 // Test frame rate goal - 30fps. |
23 const int kFrameIntervalMs = 33; | 22 const int kFrameIntervalMs = 33; |
24 | 23 |
25 static const int64 kStartMillisecond = GG_INT64_C(12345678900000); | 24 static const int64 kStartMillisecond = GG_INT64_C(12345678900000); |
26 | 25 |
27 class LoggingImplTest : public ::testing::Test { | 26 class LoggingImplTest : public ::testing::Test { |
28 protected: | 27 protected: |
29 LoggingImplTest() { | 28 LoggingImplTest() { |
30 // Enable all logging types. | 29 // Enable all logging types. |
31 config_.enable_raw_data_collection = true; | 30 config_.enable_raw_data_collection = true; |
32 config_.enable_stats_data_collection = true; | 31 config_.enable_stats_data_collection = true; |
33 config_.enable_tracing = true; | 32 config_.enable_tracing = true; |
34 | 33 |
35 testing_clock_.Advance( | 34 testing_clock_.Advance( |
36 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 35 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
37 task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_); | 36 logging_.reset(new LoggingImpl(config_)); |
38 logging_.reset(new LoggingImpl(task_runner_, config_)); | |
39 logging_->AddRawEventSubscriber(&event_subscriber_); | 37 logging_->AddRawEventSubscriber(&event_subscriber_); |
40 } | 38 } |
41 | 39 |
42 virtual ~LoggingImplTest() { | 40 virtual ~LoggingImplTest() { |
43 logging_->RemoveRawEventSubscriber(&event_subscriber_); | 41 logging_->RemoveRawEventSubscriber(&event_subscriber_); |
44 } | 42 } |
45 | 43 |
46 CastLoggingConfig config_; | 44 CastLoggingConfig config_; |
47 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | |
48 scoped_ptr<LoggingImpl> logging_; | 45 scoped_ptr<LoggingImpl> logging_; |
49 base::SimpleTestTickClock testing_clock_; | 46 base::SimpleTestTickClock testing_clock_; |
50 SimpleEventSubscriber event_subscriber_; | 47 SimpleEventSubscriber event_subscriber_; |
51 | 48 |
52 DISALLOW_COPY_AND_ASSIGN(LoggingImplTest); | 49 DISALLOW_COPY_AND_ASSIGN(LoggingImplTest); |
53 }; | 50 }; |
54 | 51 |
55 TEST_F(LoggingImplTest, BasicFrameLogging) { | 52 TEST_F(LoggingImplTest, BasicFrameLogging) { |
56 base::TimeTicks start_time = testing_clock_.NowTicks(); | 53 base::TimeTicks start_time = testing_clock_.NowTicks(); |
57 base::TimeDelta time_interval = testing_clock_.NowTicks() - start_time; | 54 base::TimeDelta time_interval = testing_clock_.NowTicks() - start_time; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 EXPECT_EQ(1u, frame_events.size()); | 351 EXPECT_EQ(1u, frame_events.size()); |
355 frame_events.clear(); | 352 frame_events.clear(); |
356 event_subscriber_2.GetFrameEventsAndReset(&frame_events); | 353 event_subscriber_2.GetFrameEventsAndReset(&frame_events); |
357 EXPECT_EQ(1u, frame_events.size()); | 354 EXPECT_EQ(1u, frame_events.size()); |
358 | 355 |
359 logging_->RemoveRawEventSubscriber(&event_subscriber_2); | 356 logging_->RemoveRawEventSubscriber(&event_subscriber_2); |
360 } | 357 } |
361 | 358 |
362 } // namespace cast | 359 } // namespace cast |
363 } // namespace media | 360 } // namespace media |
OLD | NEW |