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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "media/base/media_log.h" | 7 #include "media/base/media_log.h" |
8 #include "media/base/mock_data_source_host.h" | 8 #include "media/base/mock_data_source_host.h" |
9 #include "media/base/mock_filters.h" | 9 #include "media/base/mock_filters.h" |
10 #include "media/base/test_helpers.h" | 10 #include "media/base/test_helpers.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 using webkit_glue::MockWebFrameClient; | 31 using webkit_glue::MockWebFrameClient; |
32 using webkit_glue::MockWebURLLoader; | 32 using webkit_glue::MockWebURLLoader; |
33 | 33 |
34 namespace webkit_media { | 34 namespace webkit_media { |
35 | 35 |
36 // Overrides CreateResourceLoader() to permit injecting a MockWebURLLoader. | 36 // Overrides CreateResourceLoader() to permit injecting a MockWebURLLoader. |
37 // Also keeps track of whether said MockWebURLLoader is actively loading. | 37 // Also keeps track of whether said MockWebURLLoader is actively loading. |
38 class MockBufferedDataSource : public BufferedDataSource { | 38 class MockBufferedDataSource : public BufferedDataSource { |
39 public: | 39 public: |
40 MockBufferedDataSource(MessageLoop* message_loop, WebFrame* frame) | 40 MockBufferedDataSource( |
41 const scoped_refptr<base::MessageLoopProxy> message_loop, WebFrame* frame) | |
DaleCurtis
2013/03/01 01:36:08
&
scherkus (not reviewing)
2013/03/01 01:53:15
Done.
| |
41 : BufferedDataSource(message_loop, frame, new media::MediaLog(), | 42 : BufferedDataSource(message_loop, frame, new media::MediaLog(), |
42 base::Bind(&MockBufferedDataSource::set_downloading, | 43 base::Bind(&MockBufferedDataSource::set_downloading, |
43 base::Unretained(this))), | 44 base::Unretained(this))), |
44 downloading_(false), | 45 downloading_(false), |
45 loading_(false) { | 46 loading_(false) { |
46 } | 47 } |
47 | 48 |
48 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64)); | 49 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64)); |
49 BufferedResourceLoader* CreateMockResourceLoader(int64 first_byte_position, | 50 BufferedResourceLoader* CreateMockResourceLoader(int64 first_byte_position, |
50 int64 last_byte_position) { | 51 int64 last_byte_position) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 90 |
90 static const char kHttpUrl[] = "http://localhost/foo.webm"; | 91 static const char kHttpUrl[] = "http://localhost/foo.webm"; |
91 static const char kFileUrl[] = "file:///tmp/bar.webm"; | 92 static const char kFileUrl[] = "file:///tmp/bar.webm"; |
92 | 93 |
93 class BufferedDataSourceTest : public testing::Test { | 94 class BufferedDataSourceTest : public testing::Test { |
94 public: | 95 public: |
95 BufferedDataSourceTest() | 96 BufferedDataSourceTest() |
96 : view_(WebView::create(NULL)) { | 97 : view_(WebView::create(NULL)) { |
97 view_->initializeMainFrame(&client_); | 98 view_->initializeMainFrame(&client_); |
98 | 99 |
99 data_source_ = new MockBufferedDataSource(&message_loop_, | 100 data_source_ = new MockBufferedDataSource( |
100 view_->mainFrame()); | 101 message_loop_.message_loop_proxy(), view_->mainFrame()); |
101 data_source_->set_host(&host_); | 102 data_source_->set_host(&host_); |
102 } | 103 } |
103 | 104 |
104 virtual ~BufferedDataSourceTest() { | 105 virtual ~BufferedDataSourceTest() { |
105 view_->close(); | 106 view_->close(); |
106 } | 107 } |
107 | 108 |
108 MOCK_METHOD1(OnInitialize, void(bool)); | 109 MOCK_METHOD1(OnInitialize, void(bool)); |
109 | 110 |
110 void Initialize(const char* url, bool expected) { | 111 void Initialize(const char* url, bool expected) { |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 InitializeWithFileResponse(); | 648 InitializeWithFileResponse(); |
648 | 649 |
649 EXPECT_FALSE(data_source_->downloading()); | 650 EXPECT_FALSE(data_source_->downloading()); |
650 FinishLoading(); | 651 FinishLoading(); |
651 EXPECT_FALSE(data_source_->downloading()); | 652 EXPECT_FALSE(data_source_->downloading()); |
652 | 653 |
653 Stop(); | 654 Stop(); |
654 } | 655 } |
655 | 656 |
656 } // namespace webkit_media | 657 } // namespace webkit_media |
OLD | NEW |