1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Android test activity.
22 *//*--------------------------------------------------------------------*/
24 #include "tcuAndroidTestActivity.hpp"
25 #include "tcuAndroidUtil.hpp"
27 #include <android/window.h>
41 TestThread::TestThread (NativeActivity& activity, const CommandLine& cmdLine)
42 : RenderThread (activity)
44 , m_platform (activity)
45 , m_archive (activity.getNativeActivity()->assetManager)
46 , m_log (m_cmdLine.getLogFileName(), m_cmdLine.getLogFlags())
47 , m_app (m_platform, m_archive, m_log, m_cmdLine)
52 TestThread::~TestThread (void)
54 // \note m_testApp is managed by thread.
57 void TestThread::run (void)
62 void TestThread::onWindowCreated (ANativeWindow* window)
64 m_platform.getWindowRegistry().addWindow(window);
67 void TestThread::onWindowDestroyed (ANativeWindow* window)
69 m_platform.getWindowRegistry().destroyWindow(window);
72 void TestThread::onWindowResized (ANativeWindow* window)
75 print("Warning: Native window was resized, results may be undefined");
78 bool TestThread::render (void)
81 m_finished = !m_app.iterate();
87 TestActivity::TestActivity (ANativeActivity* activity)
88 : RenderActivity (activity)
89 , m_cmdLine (getIntentStringExtra(activity, "cmdLine"))
90 , m_testThread (*this, m_cmdLine)
93 // Set initial orientation.
94 setRequestedOrientation(getNativeActivity(), mapScreenRotation(m_cmdLine.getScreenRotation()));
96 // Set up window flags.
97 ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON |
98 AWINDOW_FLAG_TURN_SCREEN_ON |
99 AWINDOW_FLAG_FULLSCREEN |
100 AWINDOW_FLAG_SHOW_WHEN_LOCKED, 0);
103 TestActivity::~TestActivity (void)
107 void TestActivity::onStart (void)
111 setThread(&m_testThread);
112 m_testThread.start();
116 RenderActivity::onStart();
119 void TestActivity::onDestroy (void)
128 RenderActivity::onDestroy();
130 // Kill this process.
131 print("Done, killing process");
135 void TestActivity::onConfigurationChanged (void)
137 RenderActivity::onConfigurationChanged();
140 setRequestedOrientation(getNativeActivity(), mapScreenRotation(m_cmdLine.getScreenRotation()));