Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c89c8dc5 authored by Andy Hung's avatar Andy Hung
Browse files

MediaMetrics: Add unit tests

Document some interface differences.

Test: mediametrics_tests
Change-Id: Idf19827e79136dcca6522e6df53e28e3ea4a2231
parent 17dbaf28
Loading
Loading
Loading
Loading
+20 −14
Original line number Original line Diff line number Diff line
@@ -39,19 +39,25 @@ class IMediaAnalyticsService: public IInterface
public:
public:
    DECLARE_META_INTERFACE(MediaAnalyticsService);
    DECLARE_META_INTERFACE(MediaAnalyticsService);


    // generate a unique sessionID to use across multiple requests
    /**
    // 'unique' is within this device, since last reboot
     * Returns a unique sessionID to use across multiple requests;
     * 'unique' is within this device, since last reboot.
     */
    virtual MediaAnalyticsItem::SessionID_t generateUniqueSessionID() = 0;
    virtual MediaAnalyticsItem::SessionID_t generateUniqueSessionID() = 0;


    // submit the indicated record to the mediaanalytics service, where
    /**
    // it will be merged (if appropriate) with incomplete records that
     * Submits the indicated record to the mediaanalytics service, where
    // share the same key and sessionid.
     * it will be merged (if appropriate) with incomplete records that
    // 'forcenew' marks any matching incomplete record as complete before
     * share the same key and sessionID.
    // inserting this new record.
     *
    // returns the sessionID associated with that item.
     * \param item the item to submit.
    // caller continues to own the passed item
     * \param forcenew marks any matching incomplete record as complete before
     *                 inserting this new record.
     *
     * \return the sessionID associated with that item or
     *         MediaAnalyticsItem::SessionIDInvalid on failure.
     */
    virtual MediaAnalyticsItem::SessionID_t submit(MediaAnalyticsItem *item, bool forcenew) = 0;
    virtual MediaAnalyticsItem::SessionID_t submit(MediaAnalyticsItem *item, bool forcenew) = 0;

};
};


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -59,10 +65,10 @@ public:
class BnMediaAnalyticsService: public BnInterface<IMediaAnalyticsService>
class BnMediaAnalyticsService: public BnInterface<IMediaAnalyticsService>
{
{
public:
public:
    virtual status_t    onTransact( uint32_t code,
    status_t onTransact(uint32_t code,
                        const Parcel& data,
                        const Parcel& data,
                        Parcel* reply,
                        Parcel* reply,
                                    uint32_t flags = 0);
                        uint32_t flags = 0) override;
};
};


}; // namespace android
}; // namespace android
+26 −6
Original line number Original line Diff line number Diff line
@@ -5,8 +5,32 @@ cc_binary {
    name: "mediametrics",
    name: "mediametrics",


    srcs: [
    srcs: [
        "iface_statsd.cpp",
        "main_mediametrics.cpp",
        "main_mediametrics.cpp",
    ],

    shared_libs: [
        "libbinder",
        "liblog",
        "libmediaanalyticsservice",
        "libutils",
    ],

    init_rc: [
        "mediametrics.rc",
    ],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],
}

cc_library_shared {
    name: "libmediaanalyticsservice",

    srcs: [
        "iface_statsd.cpp",
        "MediaAnalyticsService.cpp",
        "MediaAnalyticsService.cpp",
        "statsd_audiopolicy.cpp",
        "statsd_audiopolicy.cpp",
        "statsd_audiorecord.cpp",
        "statsd_audiorecord.cpp",
@@ -37,16 +61,12 @@ cc_binary {
    ],
    ],


    include_dirs: [
    include_dirs: [
        "system/media/audio_utils/include"
        "system/media/audio_utils/include",
    ],
    ],


    init_rc: ["mediametrics.rc"],

    cflags: [
    cflags: [
        "-Wall",
        "-Wall",
        "-Werror",
        "-Werror",
        "-Wextra",
        "-Wextra",
    ],
    ],
    clang: true,

}
}
+18 −2
Original line number Original line Diff line number Diff line
@@ -34,8 +34,24 @@ public:
    MediaAnalyticsService();
    MediaAnalyticsService();
    ~MediaAnalyticsService() override;
    ~MediaAnalyticsService() override;


    // caller surrenders ownership of item, MediaAnalyticsService will delete.
    /**
    int64_t submit(MediaAnalyticsItem *item, bool forcenew) override;
     * Submits the indicated record to the mediaanalytics service, where
     * it will be merged (if appropriate) with incomplete records that
     * share the same key and sessionid.
     *
     * \param item the item to submit.
     * \param forcenew marks any matching incomplete record as complete before
     *                 inserting this new record.
     *
     * \return the sessionID associated with that item or
     *         MediaAnalyticsItem::SessionIDInvalid on failure.
     *
     * BEWARE: When called directly on the service (not from the binder interface),
     * the caller surrenders ownership of item, MediaAnalyticsService will delete
     * even on error.  The binder interface does not take ownership.
     * TODO: fix this inconsistency with the binder RPC interface.
     */
    MediaAnalyticsItem::SessionID_t submit(MediaAnalyticsItem *item, bool forcenew) override;


    status_t dump(int fd, const Vector<String16>& args) override;
    status_t dump(int fd, const Vector<String16>& args) override;


+25 −0
Original line number Original line Diff line number Diff line
cc_test {
    name: "mediametrics_tests",

    cflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],

    include_dirs: [
        "frameworks/av/services/mediaanalytics",
    ],

    shared_libs: [
        "libbinder",
        "liblog",
        "libmediaanalyticsservice",
        "libmediametrics",
        "libutils",
    ],

    srcs: [
        "mediametrics_tests.cpp",
    ],
}
+24 −0
Original line number Original line Diff line number Diff line
#!/bin/bash
#
# Run tests in this directory.
#

if [ -z "$ANDROID_BUILD_TOP" ]; then
    echo "Android build environment not set"
    exit -1
fi

# ensure we have mm
. $ANDROID_BUILD_TOP/build/envsetup.sh

mm

echo "waiting for device"

adb root && adb wait-for-device remount

echo "========================================"

echo "testing mediametrics"
adb push $OUT/data/nativetest/mediametrics_tests/mediametrics_tests /system/bin
adb shell /system/bin/mediametrics_tests
Loading