1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.ex.variablespeed;
18
19import android.util.Log;
20
21import java.util.concurrent.Executors;
22import java.util.concurrent.ScheduledExecutorService;
23import java.util.concurrent.TimeUnit;
24
25/** Tests for the {@link VariableSpeed} class. */
26public class VariableSpeedTest extends MediaPlayerProxyTestCase {
27    private static final String TAG = "VariableSpeedTest";
28
29    private ScheduledExecutorService mExecutor = Executors.newScheduledThreadPool(2);
30
31    @Override
32    protected void tearDown() throws Exception {
33        // I explicitly want to do super's tear-down first, because I need to get it to reset
34        // the media player before I can be confident that I can shut down the executor service.
35        super.tearDown();
36        mExecutor.shutdown();
37        if (!mExecutor.awaitTermination(10, TimeUnit.SECONDS)) {
38            Log.e(TAG, "Couldn't shut down Executor during test, check your cleanup code!");
39        }
40        mExecutor = null;
41    }
42
43    @Override
44    public MediaPlayerProxy createTestMediaPlayer() throws Exception {
45        return VariableSpeed.createVariableSpeed(mExecutor);
46    }
47}
48