• 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
30     extends Instrumentation {
31     static { System.loadLibrary("deqp"); }
32 
33     private static final String LOG_TAG =
34         "dEQP/PlatformCapabilityQueryInstrumentation";
35     private static final int CONFIGQUERYRESULT_SUPPORTED = 0;
36     private static final int CONFIGQUERYRESULT_NOT_SUPPORTED = 1;
37     private static final int CONFIGQUERYRESULT_GENERIC_ERROR = -1;
38 
39     private String m_cmdLine;
40     private String m_queryType;
41 
42     @Override
onCreate(Bundle arguments)43     public void onCreate(Bundle arguments) {
44         super.onCreate(arguments);
45 
46         m_queryType = arguments.getString("deqpQueryType");
47         m_cmdLine = arguments.getString("deqpCmdLine");
48 
49         start();
50     }
51 
52     @Override
onStart()53     public void onStart() {
54         super.onStart();
55 
56         Bundle resultInfo;
57         int resultCode = 0;
58 
59         try {
60             if ("renderConfigSupported".equals(m_queryType))
61                 resultInfo = doRenderConfigSupportedQuery();
62             else {
63                 resultInfo = new Bundle();
64                 resultInfo.putString("Error", "unknown query");
65                 resultInfo.putString("QueryType", m_queryType);
66                 resultInfo.putString("CmdLine", m_cmdLine);
67                 resultCode = 2;
68             }
69         } catch (Exception e) {
70             resultInfo = new Bundle();
71             resultInfo.putString("Error", e.getMessage());
72             resultCode = 1;
73         }
74 
75         finish(resultCode, resultInfo);
76     }
77 
doRenderConfigSupportedQuery()78     private Bundle doRenderConfigSupportedQuery() {
79         if (m_cmdLine == null)
80             throw new RuntimeException("missing command line");
81 
82         final int result = nativeRenderConfigSupportedQuery(m_cmdLine);
83 
84         if (result == CONFIGQUERYRESULT_SUPPORTED) {
85             final Bundle resultInfo = new Bundle();
86             resultInfo.putString("Supported", "Yes");
87             return resultInfo;
88         } else if (result == CONFIGQUERYRESULT_NOT_SUPPORTED) {
89             final Bundle resultInfo = new Bundle();
90             resultInfo.putString("Supported", "No");
91             return resultInfo;
92         } else if (result == CONFIGQUERYRESULT_GENERIC_ERROR)
93             throw new RuntimeException("platform query reported failure");
94         else
95             throw new RuntimeException(
96                 "platform query returned out-of-range result");
97     }
98 
nativeRenderConfigSupportedQuery(String cmdLine)99     private static native int nativeRenderConfigSupportedQuery(String cmdLine);
100 }
101