summaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2013-01-07 14:15:10 -0800
committerGeorge Mount <mount@google.com>2013-01-08 07:54:55 -0800
commite4673b2650ffc642afa872458dbf51e1a24b00c8 (patch)
tree5f4fa356b46935a41c9c9008fa0ef599642625ff /tests/src
parent44333ecb8ebb4ea172a7847731837a88719cea3f (diff)
downloadandroid_packages_apps_Snap-e4673b2650ffc642afa872458dbf51e1a24b00c8.zip
android_packages_apps_Snap-e4673b2650ffc642afa872458dbf51e1a24b00c8.tar.gz
android_packages_apps_Snap-e4673b2650ffc642afa872458dbf51e1a24b00c8.tar.bz2
Instantiate GLCanvas rather than reinitialize current GLCanvas.
GLCanvas was being used as a singleton when it really should allow separate instances for correctness. Change-Id: I650884e843a4a78997b70826f6012ae19b8df549
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java28
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/TextureTest.java9
-rw-r--r--tests/src/com/android/gallery3d/ui/GLCanvasStub.java10
3 files changed, 17 insertions, 30 deletions
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java b/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
index c42f97d..b1e6d5b 100644
--- a/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
+++ b/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
@@ -19,10 +19,6 @@ package com.android.gallery3d.glrenderer;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.GLES11Canvas;
-import com.android.gallery3d.glrenderer.GLPaint;
-
import junit.framework.TestCase;
import java.util.Arrays;
@@ -43,8 +39,7 @@ public class GLCanvasTest extends TestCase {
@SmallTest
public void testSetSize() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(glStub);
+ GLCanvas canvas = new GLES11Canvas(glStub);
canvas.setSize(100, 200);
canvas.setSize(1000, 100);
try {
@@ -62,8 +57,7 @@ public class GLCanvasTest extends TestCase {
private static class ClearBufferTest extends GLMock {
void run() {
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
assertEquals(0, mGLClearCalled);
canvas.clearBuffer();
assertEquals(GL10.GL_COLOR_BUFFER_BIT, mGLClearMask);
@@ -85,8 +79,7 @@ public class GLCanvasTest extends TestCase {
0x7F010101, 0xFEFEFDFC, 0x017F8081, 0x027F8081, 0x2ADE4C4D
};
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
canvas.setSize(400, 300);
// Test one color to make sure blend function is set.
assertEquals(0, mGLColorCalled);
@@ -114,8 +107,7 @@ public class GLCanvasTest extends TestCase {
@SmallTest
public void testSetGetMultiplyAlpha() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(glStub);
+ GLCanvas canvas = new GLES11Canvas(glStub);
canvas.setAlpha(1f);
assertEquals(1f, canvas.getAlpha());
@@ -154,8 +146,7 @@ public class GLCanvasTest extends TestCase {
private static class AlphaTest extends GLMock {
void run() {
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
canvas.setSize(400, 300);
assertEquals(0, mGLColorCalled);
@@ -197,8 +188,7 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
canvas.setSize(400, 300);
canvas.drawLine(2, 7, 1, 8, newColorPaint(0) /* color */);
assertTrue(mGLVertexArrayEnabled);
@@ -242,8 +232,7 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
canvas.setSize(400, 300);
canvas.fillRect(2, 7, 1, 8, 0 /* color */);
assertTrue(mGLVertexArrayEnabled);
@@ -305,8 +294,7 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(this);
+ GLCanvas canvas = new GLES11Canvas(this);
canvas.setSize(40, 50);
int color = 0;
diff --git a/tests/src/com/android/gallery3d/glrenderer/TextureTest.java b/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
index b13a333..956d894 100644
--- a/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
+++ b/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
@@ -69,8 +69,7 @@ public class TextureTest extends TestCase {
@SmallTest
public void testBasicTexture() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(glStub);
+ GLCanvas canvas = new GLES11Canvas(glStub);
MyBasicTexture texture = new MyBasicTexture(canvas, 47);
assertEquals(47, texture.getId());
@@ -90,8 +89,7 @@ public class TextureTest extends TestCase {
assertTrue(texture.isLoaded());
// For a different GL, it's not loaded.
- GLCanvas canvas2 = new GLES11Canvas();
- canvas2.initialize(glStub);
+ GLCanvas canvas2 = new GLES11Canvas(glStub);
assertFalse(texture.isLoaded());
assertEquals(0, texture.mOnBindCalled);
@@ -145,8 +143,7 @@ public class TextureTest extends TestCase {
@SmallTest
public void testUploadedTexture() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas();
- canvas.initialize(glStub);
+ GLCanvas canvas = new GLES11Canvas(glStub);
MyUploadedTexture texture = new MyUploadedTexture();
// draw it and the bitmap should be fetched.
diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
index d6bbc3d..da4c5c4 100644
--- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
+++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
@@ -22,6 +22,7 @@ import android.graphics.RectF;
import com.android.gallery3d.glrenderer.BasicTexture;
import com.android.gallery3d.glrenderer.GLCanvas;
+import com.android.gallery3d.glrenderer.GLId;
import com.android.gallery3d.glrenderer.GLPaint;
import com.android.gallery3d.glrenderer.RawTexture;
@@ -30,7 +31,7 @@ import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL11;
-public class GLCanvasStub extends GLCanvas {
+public class GLCanvasStub implements GLCanvas {
@Override
public void setSize(int width, int height) {}
@Override
@@ -165,12 +166,13 @@ public class GLCanvasStub extends GLCanvas {
public void drawOnlyOutsideStencil(boolean onlyOutside) {
}
@Override
- public void initialize(GL11 gl) {
- }
- @Override
public void recoverFromLightCycle() {
}
@Override
public void getBounds(Rect bounds, int x, int y, int width, int height) {
}
+ @Override
+ public GLId getGLId() {
+ return null;
+ }
}