• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program Platform Utilites
3  * ----------------------------------------------
4  *
5  * Copyright 2015 The Android Open Source Project
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  *//*!
20  * \file
21  * \brief dEQP platform capability query instrumentation
22  *//*--------------------------------------------------------------------*/
23 
24 package com.drawelements.deqp.platformutil;
25 
26 import android.app.Instrumentation;
27 import android.os.Bundle;
28 
29 public class DeqpPlatformCapabilityQueryInstrumentation extends Instrumentation
30 {
31 	static
32 	{
33 		System.loadLibrary("deqp");
34 	}
35 
36 	private static final String	LOG_TAG							= "dEQP/PlatformCapabilityQueryInstrumentation";
37 	private static final int	CONFIGQUERYRESULT_SUPPORTED		= 0;
38 	private static final int	CONFIGQUERYRESULT_NOT_SUPPORTED	= 1;
39 	private static final int	CONFIGQUERYRESULT_GENERIC_ERROR	= -1;
40 
41 	private String				m_cmdLine;
42 	private String				m_queryType;
43 
44 	@Override
onCreate(Bundle arguments)45 	public void onCreate (Bundle arguments) {
46 		super.onCreate(arguments);
47 
48 		m_queryType = arguments.getString("deqpQueryType");
49 		m_cmdLine = arguments.getString("deqpCmdLine");
50 
51 		start();
52 	}
53 
54 	@Override
onStart()55 	public void onStart () {
56 		super.onStart();
57 
58 		Bundle resultInfo;
59 		int resultCode = 0;
60 
61 		try
62 		{
63 			if ("renderConfigSupported".equals(m_queryType))
64 				resultInfo = doRenderConfigSupportedQuery();
65 			else
66 			{
67 				resultInfo = new Bundle();
68 				resultInfo.putString("Error", "unknown query");
69 				resultInfo.putString("QueryType", m_queryType);
70 				resultInfo.putString("CmdLine", m_cmdLine);
71 				resultCode = 2;
72 			}
73 		}
74 		catch (Exception e)
75 		{
76 			resultInfo = new Bundle();
77 			resultInfo.putString("Error", e.getMessage());
78 			resultCode = 1;
79 		}
80 
81 		finish(resultCode, resultInfo);
82 	}
83 
doRenderConfigSupportedQuery()84 	private Bundle doRenderConfigSupportedQuery ()
85 	{
86 		if (m_cmdLine == null)
87 			throw new RuntimeException("missing command line");
88 
89 		final int result = nativeRenderConfigSupportedQuery(m_cmdLine);
90 
91 		if (result == CONFIGQUERYRESULT_SUPPORTED)
92 		{
93 			final Bundle resultInfo = new Bundle();
94 			resultInfo.putString("Supported", "Yes");
95 			return resultInfo;
96 		}
97 		else if (result == CONFIGQUERYRESULT_NOT_SUPPORTED)
98 		{
99 			final Bundle resultInfo = new Bundle();
100 			resultInfo.putString("Supported", "No");
101 			return resultInfo;
102 		}
103 		else if (result == CONFIGQUERYRESULT_GENERIC_ERROR)
104 			throw new RuntimeException("platform query reported failure");
105 		else
106 			throw new RuntimeException("platform query returned out-of-range result");
107 	}
108 
nativeRenderConfigSupportedQuery(String cmdLine)109 	private static native int nativeRenderConfigSupportedQuery (String cmdLine);
110 }
111