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 TestApp::TestApp (NativeActivity& activity, ANativeWindow* window, const CommandLine& cmdLine)
44 , m_archive (activity.getNativeActivity()->assetManager)
45 , m_log (m_cmdLine.getLogFileName())
46 , m_app (m_platform, m_archive, m_log, m_cmdLine)
50 TestApp::~TestApp (void)
54 bool TestApp::iterate (void)
56 return m_app.iterate();
61 TestThread::TestThread (NativeActivity& activity, const CommandLine& cmdLine)
62 : RenderThread (activity)
69 TestThread::~TestThread (void)
71 // \note m_testApp is managed by thread.
74 void TestThread::run (void)
82 void TestThread::onWindowCreated (ANativeWindow* window)
84 DE_ASSERT(!m_testApp);
85 m_testApp = new TestApp(getNativeActivity(), window, m_cmdLine);
88 void TestThread::onWindowDestroyed (ANativeWindow* window)
97 // \note We could just throw exception here and RenderThread would gracefully terminate.
98 // However, native window is often destroyed when app is closed and android may not
99 // end up calling onStop().
100 die("Window was destroyed during execution");
104 void TestThread::onWindowResized (ANativeWindow* window)
106 // \todo [2013-05-12 pyry] Handle this in some sane way.
108 print("Warning: Native window was resized, results may be undefined");
111 bool TestThread::render (void)
113 DE_ASSERT(m_testApp);
114 m_done = !m_testApp->iterate();
120 TestActivity::TestActivity (ANativeActivity* activity)
121 : RenderActivity (activity)
122 , m_cmdLine (getIntentStringExtra(activity, "cmdLine"))
123 , m_testThread (*this, m_cmdLine)
125 // Provide RenderThread
126 setThread(&m_testThread);
128 // Set initial orientation.
129 setRequestedOrientation(getNativeActivity(), mapScreenRotation(m_cmdLine.getScreenRotation()));
131 // Set up window flags.
132 ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON |
133 AWINDOW_FLAG_TURN_SCREEN_ON |
134 AWINDOW_FLAG_FULLSCREEN |
135 AWINDOW_FLAG_SHOW_WHEN_LOCKED, 0);
138 TestActivity::~TestActivity (void)
142 void TestActivity::onStop (void)
144 RenderActivity::onStop();
146 // Kill this process.
147 print("Done, killing process");
151 void TestActivity::onConfigurationChanged (void)
153 RenderActivity::onConfigurationChanged();
156 setRequestedOrientation(getNativeActivity(), mapScreenRotation(m_cmdLine.getScreenRotation()));