| 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/composite_filter.h" | 7 #include "media/base/composite_filter.h" |
| 8 #include "media/base/mock_callback.h" | 8 #include "media/base/mock_callback.h" |
| 9 #include "media/base/mock_filter_host.h" | 9 #include "media/base/mock_filter_host.h" |
| 10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 base::TimeDelta seek_time); | 47 base::TimeDelta seek_time); |
| 48 | 48 |
| 49 // Helper method that calls a filter method based on the value of | 49 // Helper method that calls a filter method based on the value of |
| 50 // |method_to_call|. | 50 // |method_to_call|. |
| 51 // | 51 // |
| 52 // |method_to_call| - Indicates which method to call. | 52 // |method_to_call| - Indicates which method to call. |
| 53 // |filter| - The Filter to make the method call on. | 53 // |filter| - The Filter to make the method call on. |
| 54 // |seek_time| - The time to pass to the Seek() call if |method_to_call| | 54 // |seek_time| - The time to pass to the Seek() call if |method_to_call| |
| 55 // equals SEEK. | 55 // equals SEEK. |
| 56 // |callback| - The callback object to pass to the method. | 56 // |callback| - The callback object to pass to the method. |
| 57 // |expected_status| - Some filter methods use a FilterStatusCB instead of | 57 // |expected_status| - Some filter methods use a PipelineStatusCB instead of |
| 58 // a Closure. For these methods this function | 58 // a Closure. For these methods this function |
| 59 // creates a FilterStatusCB that makes sure the status | 59 // creates a PipelineStatusCB that makes sure the status |
| 60 // passed to the callback matches |expected_status| and | 60 // passed to the callback matches |expected_status| and |
| 61 // then calls |callback|. | 61 // then calls |callback|. |
| 62 void DoFilterCall(MethodToCall method_to_call, Filter* filter, | 62 void DoFilterCall(MethodToCall method_to_call, Filter* filter, |
| 63 base::TimeDelta seek_time, | 63 base::TimeDelta seek_time, |
| 64 const base::Closure& callback, | 64 const base::Closure& callback, |
| 65 PipelineStatus expected_status); | 65 PipelineStatus expected_status); |
| 66 | 66 |
| 67 // Creates an expectation sequence based on the value of method_to_call. | 67 // Creates an expectation sequence based on the value of method_to_call. |
| 68 // | 68 // |
| 69 // |method_to_call| - Indicates which method we want a success sequence for. | 69 // |method_to_call| - Indicates which method we want a success sequence for. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 scoped_refptr<StrictMock<MockFilter> > filter_1_; | 111 scoped_refptr<StrictMock<MockFilter> > filter_1_; |
| 112 | 112 |
| 113 // Callback passed to |filter_1_| during last Play(), Pause(), Flush(), | 113 // Callback passed to |filter_1_| during last Play(), Pause(), Flush(), |
| 114 // or Stop() call. | 114 // or Stop() call. |
| 115 base::Closure filter_1_cb_; | 115 base::Closure filter_1_cb_; |
| 116 | 116 |
| 117 // Status to pass to |filter_1_status_cb_|. | 117 // Status to pass to |filter_1_status_cb_|. |
| 118 PipelineStatus filter_1_status_; | 118 PipelineStatus filter_1_status_; |
| 119 | 119 |
| 120 // Callback passed to |filter_1_| during last Seek() call. | 120 // Callback passed to |filter_1_| during last Seek() call. |
| 121 FilterStatusCB filter_1_status_cb_; | 121 PipelineStatusCB filter_1_status_cb_; |
| 122 | 122 |
| 123 // Second filter added to the composite. | 123 // Second filter added to the composite. |
| 124 scoped_refptr<StrictMock<MockFilter> > filter_2_; | 124 scoped_refptr<StrictMock<MockFilter> > filter_2_; |
| 125 | 125 |
| 126 // Callback passed to |filter_2_| during last Play(), Pause(), Flush(), | 126 // Callback passed to |filter_2_| during last Play(), Pause(), Flush(), |
| 127 // Stop(), or Seek() call. | 127 // Stop(), or Seek() call. |
| 128 base::Closure filter_2_cb_; | 128 base::Closure filter_2_cb_; |
| 129 | 129 |
| 130 // Status to pass to |filter_2_status_cb_|. | 130 // Status to pass to |filter_2_status_cb_|. |
| 131 PipelineStatus filter_2_status_; | 131 PipelineStatus filter_2_status_; |
| 132 | 132 |
| 133 // Callback passed to |filter_2_| during last Seek() call. | 133 // Callback passed to |filter_2_| during last Seek() call. |
| 134 FilterStatusCB filter_2_status_cb_; | 134 PipelineStatusCB filter_2_status_cb_; |
| 135 | 135 |
| 136 // FilterHost implementation passed to |composite_| via set_host(). | 136 // FilterHost implementation passed to |composite_| via set_host(). |
| 137 scoped_ptr<StrictMock<MockFilterHost> > mock_filter_host_; | 137 scoped_ptr<StrictMock<MockFilterHost> > mock_filter_host_; |
| 138 | 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(CompositeFilterTest); | 139 DISALLOW_COPY_AND_ASSIGN(CompositeFilterTest); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 CompositeFilterTest::CompositeFilterTest() : | 142 CompositeFilterTest::CompositeFilterTest() : |
| 143 composite_(new CompositeFilter(&message_loop_)), | 143 composite_(new CompositeFilter(&message_loop_)), |
| 144 filter_1_status_(PIPELINE_OK), | 144 filter_1_status_(PIPELINE_OK), |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 NewExpectedStatusCB(PIPELINE_OK)); | 788 NewExpectedStatusCB(PIPELINE_OK)); |
| 789 | 789 |
| 790 // Issue a Play() and expect no errors. | 790 // Issue a Play() and expect no errors. |
| 791 composite_->Play(NewExpectedClosure()); | 791 composite_->Play(NewExpectedClosure()); |
| 792 | 792 |
| 793 // Issue a Stop() and expect no errors. | 793 // Issue a Stop() and expect no errors. |
| 794 composite_->Stop(NewExpectedClosure()); | 794 composite_->Stop(NewExpectedClosure()); |
| 795 } | 795 } |
| 796 | 796 |
| 797 } // namespace media | 797 } // namespace media |
| OLD | NEW |