diff options
author | Nicolas Catania <niko@google.com> | 2009-07-13 14:37:49 -0700 |
---|---|---|
committer | Nicolas Catania <niko@google.com> | 2009-07-16 11:22:31 -0700 |
commit | 8f5fcab05f1d6f644a9c30f012b8ff302f24a118 (patch) | |
tree | 55cd20372765a9f652b41eda82cef1f24063bbfb /media/tests/players | |
parent | 358efe418eae266734a16e9ae8f26043e9c64f05 (diff) | |
download | frameworks_base-8f5fcab05f1d6f644a9c30f012b8ff302f24a118.zip frameworks_base-8f5fcab05f1d6f644a9c30f012b8ff302f24a118.tar.gz frameworks_base-8f5fcab05f1d6f644a9c30f012b8ff302f24a118.tar.bz2 |
New test player stub to load mock native players.
Added a new class TestPlayerStub that takes a magic url in the setDataSource call.
Based on the value of the url, the stub is going to load a DL and create the concrete
player used during the test.
After these initialization steps TestPlayerStub is just a wrapper.
Added a new functional test MediaPlayerInvokeTest to demonstrate how a new
mock player to test the invoke method can be loaded.
Added a new mock player for the invoke test: invoke_mock_media_player.cpp.
Diffstat (limited to 'media/tests/players')
-rw-r--r-- | media/tests/players/Android.mk | 29 | ||||
-rw-r--r-- | media/tests/players/README | 8 | ||||
-rw-r--r-- | media/tests/players/invoke_mock_media_player.cpp | 118 |
3 files changed, 155 insertions, 0 deletions
diff --git a/media/tests/players/Android.mk b/media/tests/players/Android.mk new file mode 100644 index 0000000..eb50a51 --- /dev/null +++ b/media/tests/players/Android.mk @@ -0,0 +1,29 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= invoke_mock_media_player.cpp + +LOCAL_SHARED_LIBRARIES:= \ + libbinder \ + libutils + +LOCAL_MODULE:= invoke_mock_media_player +LOCAL_MODULE_TAGS := test eng +LOCAL_PRELINK_MODULE:= false + +include $(BUILD_SHARED_LIBRARY) diff --git a/media/tests/players/README b/media/tests/players/README new file mode 100644 index 0000000..edf9bd6 --- /dev/null +++ b/media/tests/players/README @@ -0,0 +1,8 @@ +Native test players for system tests. + +For functional/system/performance tests, a native test player can be used. +This directory contains the sources of such players. +The class TestPlayerStub uses the dynamic loader to load any of them. + + + diff --git a/media/tests/players/invoke_mock_media_player.cpp b/media/tests/players/invoke_mock_media_player.cpp new file mode 100644 index 0000000..f02298d --- /dev/null +++ b/media/tests/players/invoke_mock_media_player.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "TestPlayerStub" +#include "utils/Log.h" + +#include <string.h> + +#include "binder/Parcel.h" +#include "media/MediaPlayerInterface.h" +#include "utils/Errors.h" + +using android::ISurface; +using android::MediaPlayerBase; +using android::OK; +using android::Parcel; +using android::TEST_PLAYER; +using android::UNKNOWN_ERROR; +using android::player_type; +using android::sp; +using android::status_t; + +// This file contains a test player that is loaded via the +// TestPlayerStub class. The player contains various implementation +// of the invoke method that java tests can use. + +namespace { +const char *kPing = "ping"; + +class Player: public MediaPlayerBase +{ + public: + enum TestType {TEST_UNKNOWN, PING}; + Player() {} + virtual ~Player() {} + + virtual status_t initCheck() {return OK;} + virtual bool hardwareOutput() {return true;} + + virtual status_t setDataSource(const char *url) { + LOGV("setDataSource %s", url); + mTest = TEST_UNKNOWN; + if (strncmp(url, kPing, strlen(kPing)) == 0) { + mTest = PING; + } + return OK; + } + + virtual status_t setDataSource(int fd, int64_t offset, int64_t length) {return OK;} + virtual status_t setVideoSurface(const sp<ISurface>& surface) {return OK;} + virtual status_t prepare() {return OK;} + virtual status_t prepareAsync() {return OK;} + virtual status_t start() {return OK;} + virtual status_t stop() {return OK;} + virtual status_t pause() {return OK;} + virtual bool isPlaying() {return true;} + virtual status_t seekTo(int msec) {return OK;} + virtual status_t getCurrentPosition(int *msec) {return OK;} + virtual status_t getDuration(int *msec) {return OK;} + virtual status_t reset() {return OK;} + virtual status_t setLooping(int loop) {return OK;} + virtual player_type playerType() {return TEST_PLAYER;} + virtual status_t invoke(const Parcel& request, Parcel *reply); + private: + // Take a request, copy it to the reply. + void ping(const Parcel& request, Parcel *reply); + + status_t mStatus; + TestType mTest; +}; + +status_t Player::invoke(const Parcel& request, Parcel *reply) +{ + switch (mTest) { + case PING: + ping(request, reply); + break; + default: mStatus = UNKNOWN_ERROR; + } + return mStatus; +} + +void Player::ping(const Parcel& request, Parcel *reply) +{ + const size_t len = request.dataAvail(); + + reply->setData(static_cast<const uint8_t*>(request.readInplace(len)), len); + mStatus = OK; +} + +} + +extern "C" android::MediaPlayerBase* newPlayer() +{ + LOGD("New invoke test player"); + return new Player(); +} + +extern "C" android::status_t deletePlayer(android::MediaPlayerBase *player) +{ + LOGD("Delete invoke test player"); + delete player; + return OK; +} |