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

Commit 62211c9b authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Build hwui test scenes as common test code"

parents 87a845ce 27e58b4f
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -90,6 +90,9 @@ hwui_src_files := \
    protos/hwui.proto
    protos/hwui.proto


hwui_test_common_src_files := \
hwui_test_common_src_files := \
    $(call all-cpp-files-under, tests/common/scenes) \
    tests/common/TestContext.cpp \
    tests/common/TestScene.cpp \
    tests/common/TestUtils.cpp
    tests/common/TestUtils.cpp


hwui_cflags := \
hwui_cflags := \
@@ -259,12 +262,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static


LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
    $(hwui_test_common_src_files) \
    $(hwui_test_common_src_files) \
    tests/macrobench/TestContext.cpp \
    tests/macrobench/TestSceneRunner.cpp \
    tests/macrobench/TestSceneRunner.cpp \
    tests/macrobench/main.cpp
    tests/macrobench/main.cpp


LOCAL_SRC_FILES += $(call all-cpp-files-under, tests/common/scenes)

include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)


# ------------------------
# ------------------------
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include "TestContext.h"
#include "tests/common/TestContext.h"


namespace android {
namespace android {
namespace uirenderer {
namespace uirenderer {
+10 −35
Original line number Original line Diff line number Diff line
@@ -13,49 +13,24 @@
 * See the License for the specific language governing permissions and
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * limitations under the License.
 */
 */
#ifndef TESTS_BENCHMARK_H
#define TESTS_BENCHMARK_H


#include "tests/common/TestScene.h"
#include "tests/common/TestScene.h"


#include <string>
#include <vector>

namespace android {
namespace android {
namespace uirenderer {
namespace uirenderer {
namespace test {


struct BenchmarkOptions {
// Not a static global because we need to force the map to be constructed
    int count;
// before we try to add things to it.
};
std::unordered_map<std::string, TestScene::Info>& TestScene::testMap() {

    static std::unordered_map<std::string, TestScene::Info> testMap;
typedef test::TestScene* (*CreateScene)(const BenchmarkOptions&);
    return testMap;

template <class T>
test::TestScene* simpleCreateScene(const BenchmarkOptions&) {
    return new T();
}
}


struct BenchmarkInfo {
void TestScene::registerScene(const TestScene::Info& info) {
    std::string name;
    testMap()[info.name] = info;
    std::string description;
    CreateScene createScene;
};

class Benchmark {
public:
    Benchmark(const BenchmarkInfo& info) {
        registerBenchmark(info);
}
}


private:
} /* namespace test */
    Benchmark() = delete;
    Benchmark(const Benchmark&) = delete;
    Benchmark& operator=(const Benchmark&) = delete;

    static void registerBenchmark(const BenchmarkInfo& info);
};

} /* namespace uirenderer */
} /* namespace uirenderer */
} /* namespace android */
} /* namespace android */

#endif /* TESTS_BENCHMARK_H */
+34 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@
#ifndef TESTS_TESTSCENE_H
#ifndef TESTS_TESTSCENE_H
#define TESTS_TESTSCENE_H
#define TESTS_TESTSCENE_H


#include <string>
#include <unordered_map>

namespace android {
namespace android {
namespace uirenderer {
namespace uirenderer {
class RenderNode;
class RenderNode;
@@ -32,9 +35,40 @@ namespace test {


class TestScene {
class TestScene {
public:
public:
    struct Options {
        int count = 0;
    };

    template <class T>
    static test::TestScene* simpleCreateScene(const TestScene::Options&) {
        return new T();
    }

    typedef test::TestScene* (*CreateScene)(const TestScene::Options&);

    struct Info {
        std::string name;
        std::string description;
        CreateScene createScene;
    };

    class Registrar {
    public:
        Registrar(const TestScene::Info& info) {
            TestScene::registerScene(info);
        }
    private:
        Registrar() = delete;
        Registrar(const Registrar&) = delete;
        Registrar& operator=(const Registrar&) = delete;
    };

    virtual ~TestScene() {}
    virtual ~TestScene() {}
    virtual void createContent(int width, int height, TestCanvas& renderer) = 0;
    virtual void createContent(int width, int height, TestCanvas& renderer) = 0;
    virtual void doFrame(int frameNr) = 0;
    virtual void doFrame(int frameNr) = 0;

    static std::unordered_map<std::string, Info>& testMap();
    static void registerScene(const Info& info);
};
};


} // namespace test
} // namespace test
Loading