• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
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  * Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
20  * License. You may obtain a copy of the License at
21  *
22  * http://www.apache.org/licenses/LICENSE-2.0
23  *
24  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
25  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
26  * governing permissions and limitations under the License.
27  */
28 
29 package com.badlogic.gdx.tests.utils;
30 
31 import java.io.BufferedReader;
32 import java.io.InputStream;
33 import java.io.InputStreamReader;
34 import java.util.ArrayList;
35 import java.util.Arrays;
36 import java.util.Collections;
37 import java.util.List;
38 
39 import com.badlogic.gdx.tests.*;
40 import com.badlogic.gdx.tests.bench.TiledMapBench;
41 import com.badlogic.gdx.tests.conformance.DisplayModeTest;
42 import com.badlogic.gdx.tests.examples.MoveSpriteExample;
43 import com.badlogic.gdx.tests.extensions.ControllersTest;
44 import com.badlogic.gdx.tests.extensions.FreeTypeAtlasTest;
45 import com.badlogic.gdx.tests.extensions.FreeTypeDisposeTest;
46 import com.badlogic.gdx.tests.extensions.FreeTypeFontLoaderTest;
47 import com.badlogic.gdx.tests.extensions.FreeTypeIncrementalTest;
48 import com.badlogic.gdx.tests.extensions.FreeTypeMetricsTest;
49 import com.badlogic.gdx.tests.extensions.FreeTypePackTest;
50 import com.badlogic.gdx.tests.extensions.FreeTypeTest;
51 import com.badlogic.gdx.tests.extensions.InternationalFontsTest;
52 import com.badlogic.gdx.tests.g3d.Animation3DTest;
53 import com.badlogic.gdx.tests.g3d.Basic3DSceneTest;
54 import com.badlogic.gdx.tests.g3d.Basic3DTest;
55 import com.badlogic.gdx.tests.g3d.Benchmark3DTest;
56 import com.badlogic.gdx.tests.g3d.FogTest;
57 import com.badlogic.gdx.tests.g3d.FrameBufferCubemapTest;
58 import com.badlogic.gdx.tests.g3d.HeightMapTest;
59 import com.badlogic.gdx.tests.g3d.LightsTest;
60 import com.badlogic.gdx.tests.g3d.MaterialTest;
61 import com.badlogic.gdx.tests.g3d.MeshBuilderTest;
62 import com.badlogic.gdx.tests.g3d.ModelCacheTest;
63 import com.badlogic.gdx.tests.g3d.ModelTest;
64 import com.badlogic.gdx.tests.g3d.MultipleRenderTargetTest;
65 import com.badlogic.gdx.tests.g3d.ParticleControllerTest;
66 import com.badlogic.gdx.tests.g3d.ShaderCollectionTest;
67 import com.badlogic.gdx.tests.g3d.ShaderTest;
68 import com.badlogic.gdx.tests.g3d.ShadowMappingTest;
69 import com.badlogic.gdx.tests.g3d.SkeletonTest;
70 import com.badlogic.gdx.tests.g3d.TextureArrayTest;
71 import com.badlogic.gdx.tests.g3d.TextureRegion3DTest;
72 import com.badlogic.gdx.tests.gles2.HelloTriangle;
73 import com.badlogic.gdx.tests.gles2.SimpleVertexShader;
74 import com.badlogic.gdx.tests.net.NetAPITest;
75 import com.badlogic.gdx.tests.superkoalio.SuperKoalio;
76 import com.badlogic.gdx.utils.ObjectMap;
77 import com.badlogic.gdx.utils.StreamUtils;
78 
79 /** List of GdxTest classes. To be used by the test launchers. If you write your own test, add it in here!
80  *
81  * @author badlogicgames@gmail.com */
82 public class GdxTests {
83 	public static final List<Class<? extends GdxTest>> tests = new ArrayList<Class<? extends GdxTest>>(Arrays.asList(
84 		// @off
85 		IssueTest.class,
86 		AccelerometerTest.class,
87 		ActionSequenceTest.class,
88 		ActionTest.class,
89 		Affine2Test.class,
90 		AlphaTest.class,
91 		Animation3DTest.class,
92 		AnimationTest.class,
93 		AnnotationTest.class,
94 		AssetManagerTest.class,
95 		AtlasIssueTest.class,
96 		AudioDeviceTest.class,
97 		AudioRecorderTest.class,
98 		Basic3DSceneTest.class,
99 		Basic3DTest.class,
100 		Benchmark3DTest.class,
101 		BitmapFontAlignmentTest.class,
102 		BitmapFontDistanceFieldTest.class,
103 		BitmapFontFlipTest.class,
104 		BitmapFontMetricsTest.class,
105 		BitmapFontTest.class,
106 		BitmapFontAtlasRegionTest.class,
107 		BlitTest.class,
108 		Box2DTest.class,
109 		Box2DTestCollection.class,
110 		Bresenham2Test.class,
111 		BufferUtilsTest.class,
112 		BulletTestCollection.class,
113 		CollectionsTest.class,
114 		ColorTest.class,
115 		ContainerTest.class,
116 		CpuSpriteBatchTest.class,
117 		CullTest.class,
118 		CursorTest.class,
119 		DelaunayTriangulatorTest.class,
120 		DeltaTimeTest.class,
121 		DirtyRenderingTest.class,
122 		DragAndDropTest.class,
123 		ETC1Test.class,
124 //		EarClippingTriangulatorTest.class,
125 		EdgeDetectionTest.class,
126 		DisplayModeTest.class,
127 		ExitTest.class,
128 		ExternalMusicTest.class,
129 		FilesTest.class,
130 		FilterPerformanceTest.class,
131 		FloatTextureTest.class,
132 		FogTest.class,
133 		FrameBufferCubemapTest.class,
134 		FrameBufferTest.class,
135 		FramebufferToTextureTest.class,
136 		FullscreenTest.class,
137 		ControllersTest.class,
138 		Gdx2DTest.class,
139 		GestureDetectorTest.class,
140 		GLES30Test.class,
141 		GLProfilerErrorTest.class,
142 		GroupCullingTest.class,
143 		GroupFadeTest.class,
144 		GroupTest.class,
145 		HeightMapTest.class,
146 		HelloTriangle.class,
147 		HexagonalTiledMapTest.class,
148 		I18NMessageTest.class,
149 		I18NSimpleMessageTest.class,
150 		ImageScaleTest.class,
151 		ImageTest.class,
152 		ImmediateModeRendererTest.class,
153 		IndexBufferObjectShaderTest.class,
154 		InputTest.class,
155 		IntegerBitmapFontTest.class,
156 		InterpolationTest.class,
157 		InverseKinematicsTest.class,
158 		IsometricTileTest.class,
159 		KinematicBodyTest.class,
160 		KTXTest.class,
161 		LabelScaleTest.class,
162 		LabelTest.class,
163 		LifeCycleTest.class,
164 		LightsTest.class,
165 		MaterialTest.class,
166 		MatrixJNITest.class,
167 		MeshBuilderTest.class,
168 		MeshShaderTest.class,
169 		MipMapTest.class,
170 		ModelTest.class,
171 		ModelCacheTest.class,
172 		MoveSpriteExample.class,
173 		MultipleRenderTargetTest.class,
174 		MultitouchTest.class,
175 		MusicTest.class,
176 		NetAPITest.class,
177 		NinePatchTest.class,
178 		OnscreenKeyboardTest.class,
179 		PathTest.class,
180 		ParallaxTest.class,
181 		ParticleControllerTest.class,
182 		ParticleEmitterTest.class,
183 		ParticleEmittersTest.class,
184 		PixelsPerInchTest.class,
185 		PixmapBlendingTest.class,
186 		PixmapPackerTest.class,
187 		PixmapTest.class,
188 		PolygonRegionTest.class,
189 		PolygonSpriteTest.class,
190 		PreferencesTest.class,
191 		ProjectTest.class,
192 		ProjectiveTextureTest.class,
193 		ReflectionTest.class,
194 		RotationTest.class,
195 		RunnablePostTest.class,
196 		StageDebugTest.class,
197 		Scene2dTest.class,
198 		ScrollPane2Test.class,
199 		ScrollPaneScrollBarsTest.class,
200 		ScrollPaneTest.class,
201 		SelectTest.class,
202 		ShaderCollectionTest.class,
203 		ShaderMultitextureTest.class,
204 		ShaderTest.class,
205 		ShadowMappingTest.class,
206 		ShapeRendererTest.class,
207 		SimpleAnimationTest.class,
208 		SimpleDecalTest.class,
209 		SimpleStageCullingTest.class,
210 		SimpleVertexShader.class,
211 		SkeletonTest.class,
212 		SoftKeyboardTest.class,
213 		SortedSpriteTest.class,
214 		SoundTest.class,
215 		SpriteBatchRotationTest.class,
216 		SpriteBatchShaderTest.class,
217 		SpriteBatchTest.class,
218 		SpriteCacheOffsetTest.class,
219 		SpriteCacheTest.class,
220 		StagePerformanceTest.class,
221 		StageTest.class,
222 		SuperKoalio.class,
223 		TableLayoutTest.class,
224 		TableTest.class,
225 		TextAreaTest.class,
226 		TextButtonTest.class,
227 		TextInputDialogTest.class,
228 		TextureAtlasTest.class,
229 		TextureArrayTest.class,
230 		TextureDataTest.class,
231 		TextureDownloadTest.class,
232 		TextureFormatTest.class,
233 		TextureRegion3DTest.class,
234 		TideMapAssetManagerTest.class,
235 		TideMapDirectLoaderTest.class,
236 		TileTest.class,
237 		TiledMapAssetManagerTest.class,
238 		TiledMapAtlasAssetManagerTest.class,
239 		TiledMapDirectLoaderTest.class,
240 		TiledMapModifiedExternalTilesetTest.class,
241 		TiledMapObjectLoadingTest.class,
242 		TiledMapBench.class,
243 		TimerTest.class,
244 		TimeUtilsTest.class,
245 		TouchpadTest.class,
246 		TreeTest.class,
247 		UISimpleTest.class,
248 		UITest.class,
249 		VBOWithVAOPerformanceTest.class,
250 		Vector2dTest.class,
251 		VertexBufferObjectShaderTest.class,
252 		VibratorTest.class,
253 		ViewportTest1.class,
254 		ViewportTest2.class,
255 		ViewportTest3.class,
256 		YDownTest.class,
257 		FreeTypeFontLoaderTest.class,
258 		FreeTypeDisposeTest.class,
259 		FreeTypeMetricsTest.class,
260 		FreeTypeIncrementalTest.class,
261 		FreeTypePackTest.class,
262 		FreeTypeAtlasTest.class,
263 		FreeTypeTest.class,
264 		InternationalFontsTest.class,
265 		PngTest.class,
266 		JsonTest.class
267 		// @on
268 
269 		// SoundTouchTest.class, Mpg123Test.class, WavTest.class, FreeTypeTest.class,
270 		// VorbisTest.class
271 		));
272 
273 	static final ObjectMap<String, String> obfuscatedToOriginal = new ObjectMap();
274 	static final ObjectMap<String, String> originalToObfuscated = new ObjectMap();
275 	static {
276 		InputStream mappingInput = GdxTests.class.getResourceAsStream("/mapping.txt");
277 		if (mappingInput != null) {
278 			BufferedReader reader = null;
279 			try {
280 				reader = new BufferedReader(new InputStreamReader(mappingInput), 512);
281 				while (true) {
282 					String line = reader.readLine();
283 					if (line == null) break;
284 					if (line.startsWith("    ")) continue;
285 					String[] split = line.replace(":", "").split(" -> ");
286 					String original = split[0];
287 					if (original.indexOf('.') != -1) original = original.substring(original.lastIndexOf('.') + 1);
originalToObfuscated.put(original, split[1])288 					originalToObfuscated.put(original, split[1]);
obfuscatedToOriginal.put(split[1], original)289 					obfuscatedToOriginal.put(split[1], original);
290 				}
reader.close()291 				reader.close();
292 			} catch (Exception ex) {
293 				System.out.println("GdxTests: Error reading mapping file: mapping.txt");
294 				ex.printStackTrace();
295 			} finally {
296 				StreamUtils.closeQuietly(reader);
297 			}
298 		}
299 	}
300 
getNames()301 	public static List<String> getNames () {
302 		List<String> names = new ArrayList<String>(tests.size());
303 		for (Class clazz : tests)
304 			names.add(obfuscatedToOriginal.get(clazz.getSimpleName(), clazz.getSimpleName()));
305 		Collections.sort(names);
306 		return names;
307 	}
308 
forName(String name)309 	private static Class<? extends GdxTest> forName (String name) {
310 		name = originalToObfuscated.get(name, name);
311 		for (Class clazz : tests)
312 			if (clazz.getSimpleName().equals(name)) return clazz;
313 		return null;
314 	}
315 
newTest(String testName)316 	public static GdxTest newTest (String testName) {
317 		testName = originalToObfuscated.get(testName, testName);
318 		try {
319 			return forName(testName).newInstance();
320 		} catch (InstantiationException e) {
321 			e.printStackTrace();
322 		} catch (IllegalAccessException e) {
323 			e.printStackTrace();
324 		}
325 		return null;
326 	}
327 }
328