1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief CTS Android Activity.
23 */ /*-------------------------------------------------------------------*/
25 #include "glcAndroidTestActivity.hpp"
26 #include "glcTestRunner.hpp"
27 #include "tcuAndroidAssets.hpp"
28 #include "tcuAndroidPlatform.hpp"
29 #include "tcuAndroidUtil.hpp"
31 #include <android/window.h>
39 using tcu::Android::Platform;
40 using tcu::Android::AssetArchive;
41 using tcu::Android::NativeActivity;
43 static const char* DEFAULT_LOG_PATH = "/sdcard";
45 static std::string getLogPath(ANativeActivity* activity)
47 std::string path = tcu::Android::getIntentStringExtra(activity, "logdir");
48 return path.empty() ? std::string(DEFAULT_LOG_PATH) : path;
51 static deUint32 getFlags(ANativeActivity* activity)
54 if (tcu::Android::getIntentStringExtra(activity, "verbose") == "true")
55 flags |= TestRunner::VERBOSE_ALL;
56 else if (tcu::Android::getIntentStringExtra(activity, "summary") == "true")
57 flags |= TestRunner::PRINT_SUMMARY;
61 TestThread::TestThread(NativeActivity& activity, tcu::Android::AssetArchive& archive, const std::string& logPath,
62 glu::ApiType runType, deUint32 runFlags)
63 : RenderThread(activity)
64 , m_platform(activity)
66 , m_app(m_platform, m_archive, logPath.c_str(), runType, runFlags)
71 TestThread::~TestThread(void)
73 // \note m_testApp is managed by thread.
76 void TestThread::run(void)
81 void TestThread::onWindowCreated(ANativeWindow* window)
83 m_platform.getWindowRegistry().addWindow(window);
86 void TestThread::onWindowDestroyed(ANativeWindow* window)
88 m_platform.getWindowRegistry().destroyWindow(window);
91 void TestThread::onWindowResized(ANativeWindow* window)
93 // \todo [2013-05-12 pyry] Handle this in some sane way.
95 tcu::print("Warning: Native window was resized, results may be undefined");
98 bool TestThread::render(void)
101 m_finished = !m_app.iterate();
107 TestActivity::TestActivity(ANativeActivity* activity, glu::ApiType runType)
108 : RenderActivity(activity)
109 , m_archive(activity->assetManager)
110 , m_cmdLine(tcu::Android::getIntentStringExtra(activity, "cmdLine"))
111 , m_testThread(*this, m_archive, getLogPath(activity), runType, getFlags(activity))
114 // Set initial orientation.
115 tcu::Android::setRequestedOrientation(getNativeActivity(),
116 tcu::Android::mapScreenRotation(m_cmdLine.getScreenRotation()));
118 // Set up window flags.
119 ANativeActivity_setWindowFlags(activity,
120 AWINDOW_FLAG_KEEP_SCREEN_ON | AWINDOW_FLAG_TURN_SCREEN_ON | AWINDOW_FLAG_FULLSCREEN |
121 AWINDOW_FLAG_SHOW_WHEN_LOCKED,
125 TestActivity::~TestActivity(void)
129 void TestActivity::onStart(void)
133 setThread(&m_testThread);
134 m_testThread.start();
138 RenderActivity::onStart();
141 void TestActivity::onDestroy(void)
150 RenderActivity::onDestroy();
152 // Kill this process.
153 tcu::print("Done, killing process");
157 void TestActivity::onConfigurationChanged(void)
159 RenderActivity::onConfigurationChanged();
162 tcu::Android::setRequestedOrientation(getNativeActivity(),
163 tcu::Android::mapScreenRotation(m_cmdLine.getScreenRotation()));