1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.webgl.cts; 18 19 import android.util.Log; 20 import android.webgl.cts.R; 21 import android.webgl.WebGLActivity; 22 import java.lang.Override; 23 import java.io.File; 24 import java.io.InputStream; 25 26 /** 27 * A Singleton class to wrap the WebGL Conformance Test Suite. 28 */ 29 public class WebGLConformanceSuite { 30 private final String TAG = "WebGLConformanceSuite"; 31 private static volatile WebGLConformanceSuite mInstance = null; 32 WebGLConformanceSuite(WebGLActivity activity)33 private WebGLConformanceSuite(WebGLActivity activity) throws Exception { 34 Log.i(TAG, "Unzipping WebGL Conformance Suite: " 35 + activity.getCacheDir().getPath()); 36 InputStream suite = activity.getResources().openRawResource(R.raw.webgl_sdk_tests); 37 ZipUtil.unzipToPath(suite, activity.getCacheDir()); 38 InputStream harness = activity.getResources().openRawResource(R.raw.harness); 39 ZipUtil.streamToPath(harness, activity.getCacheDir(), "harness.html"); 40 } 41 init(WebGLActivity activity)42 public static WebGLConformanceSuite init(WebGLActivity activity) 43 throws Exception { 44 if (mInstance == null) { 45 synchronized (WebGLConformanceSuite.class) { 46 mInstance = new WebGLConformanceSuite(activity); 47 } 48 } 49 return mInstance; 50 } 51 } 52