| 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 reader->Reset(); | 418 reader->Reset(); |
| 419 message_loop_.RunAllPending(); | 419 message_loop_.RunAllPending(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // A mocked callback specialization for calling Read(). Since RunWithParams() | 422 // A mocked callback specialization for calling Read(). Since RunWithParams() |
| 423 // is mocked we don't need to pass in object or method pointers. | 423 // is mocked we don't need to pass in object or method pointers. |
| 424 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> { | 424 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> { |
| 425 public: | 425 public: |
| 426 MockReadCB() {} | 426 MockReadCB() {} |
| 427 | 427 |
| 428 MOCK_METHOD0(OnDelete, void()); |
| 429 MOCK_METHOD1(Run, void(const scoped_refptr<Buffer>& buffer)); |
| 430 |
| 431 protected: |
| 432 friend class base::RefCountedThreadSafe<MockReadCB>; |
| 428 virtual ~MockReadCB() { | 433 virtual ~MockReadCB() { |
| 429 OnDelete(); | 434 OnDelete(); |
| 430 } | 435 } |
| 431 | 436 |
| 432 MOCK_METHOD0(OnDelete, void()); | |
| 433 MOCK_METHOD1(Run, void(const scoped_refptr<Buffer>& buffer)); | |
| 434 | |
| 435 private: | 437 private: |
| 436 DISALLOW_COPY_AND_ASSIGN(MockReadCB); | 438 DISALLOW_COPY_AND_ASSIGN(MockReadCB); |
| 437 }; | 439 }; |
| 438 | 440 |
| 439 TEST_F(FFmpegDemuxerTest, Stop) { | 441 TEST_F(FFmpegDemuxerTest, Stop) { |
| 440 // Tests that calling Read() on a stopped demuxer stream immediately deletes | 442 // Tests that calling Read() on a stopped demuxer stream immediately deletes |
| 441 // the callback. | 443 // the callback. |
| 442 CreateDemuxer("bear-320x240.webm"); | 444 CreateDemuxer("bear-320x240.webm"); |
| 443 InitializeDemuxer(); | 445 InitializeDemuxer(); |
| 444 | 446 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 message_loop_.RunAllPending(); | 714 message_loop_.RunAllPending(); |
| 713 EXPECT_TRUE(reader->called()); | 715 EXPECT_TRUE(reader->called()); |
| 714 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); | 716 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); |
| 715 | 717 |
| 716 // Manually release the last reference to the buffer and verify it was freed. | 718 // Manually release the last reference to the buffer and verify it was freed. |
| 717 reader->Reset(); | 719 reader->Reset(); |
| 718 message_loop_.RunAllPending(); | 720 message_loop_.RunAllPending(); |
| 719 } | 721 } |
| 720 | 722 |
| 721 } // namespace media | 723 } // namespace media |
| OLD | NEW |