summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/gallery3d/ui')
-rw-r--r--tests/src/com/android/gallery3d/ui/GLCanvasStub.java78
-rw-r--r--tests/src/com/android/gallery3d/ui/GLCanvasTest.java31
-rw-r--r--tests/src/com/android/gallery3d/ui/TextureTest.java11
3 files changed, 101 insertions, 19 deletions
diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
index 5a08b8599..e9932239b 100644
--- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
+++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
@@ -16,52 +16,77 @@
package com.android.gallery3d.ui;
+import android.graphics.Bitmap;
import android.graphics.RectF;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+
import javax.microedition.khronos.opengles.GL11;
-public class GLCanvasStub implements GLCanvas {
+public class GLCanvasStub extends GLCanvas {
+ @Override
public void setSize(int width, int height) {}
+ @Override
public void clearBuffer() {}
+ @Override
public void clearBuffer(float[] argb) {}
public void setCurrentAnimationTimeMillis(long time) {}
public long currentAnimationTimeMillis() {
throw new UnsupportedOperationException();
}
+ @Override
public void setAlpha(float alpha) {}
+ @Override
public float getAlpha() {
throw new UnsupportedOperationException();
}
+ @Override
public void multiplyAlpha(float alpha) {}
+ @Override
public void translate(float x, float y, float z) {}
+ @Override
public void translate(float x, float y) {}
+ @Override
public void scale(float sx, float sy, float sz) {}
+ @Override
public void rotate(float angle, float x, float y, float z) {}
public boolean clipRect(int left, int top, int right, int bottom) {
throw new UnsupportedOperationException();
}
+ @Override
public void save() {
throw new UnsupportedOperationException();
}
+ @Override
public void save(int saveFlags) {
throw new UnsupportedOperationException();
}
public void setBlendEnabled(boolean enabled) {}
+ @Override
public void restore() {}
+ @Override
public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint) {}
+ @Override
public void drawRect(float x1, float y1, float x2, float y2, GLPaint paint) {}
+ @Override
public void fillRect(float x, float y, float width, float height, int color) {}
+ @Override
public void drawTexture(
BasicTexture texture, int x, int y, int width, int height) {}
+ @Override
public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
int uvBuffer, int indexBuffer, int indexCount) {}
public void drawTexture(BasicTexture texture,
int x, int y, int width, int height, float alpha) {}
+ @Override
public void drawTexture(BasicTexture texture, RectF source, RectF target) {}
+ @Override
public void drawTexture(BasicTexture texture, float[] mTextureTransform,
int x, int y, int w, int h) {}
public void drawMixed(BasicTexture from, BasicTexture to,
float ratio, int x, int y, int w, int h) {}
+ @Override
public void drawMixed(BasicTexture from, int to,
float ratio, int x, int y, int w, int h) {}
public void drawMixed(BasicTexture from, BasicTexture to,
@@ -72,17 +97,68 @@ public class GLCanvasStub implements GLCanvas {
public GL11 getGLInstance() {
throw new UnsupportedOperationException();
}
+ @Override
public boolean unloadTexture(BasicTexture texture) {
throw new UnsupportedOperationException();
}
+ @Override
public void deleteBuffer(int bufferId) {
throw new UnsupportedOperationException();
}
+ @Override
public void deleteRecycledResources() {}
+ @Override
public void multiplyMatrix(float[] mMatrix, int offset) {}
+ @Override
public void dumpStatisticsAndClear() {}
+ @Override
public void beginRenderTarget(RawTexture texture) {}
+ @Override
public void endRenderTarget() {}
+ @Override
public void drawMixed(BasicTexture from, int toColor,
float ratio, RectF src, RectF target) {}
+
+ @Override
+ public void setTextureParameters(BasicTexture texture) {
+ }
+ @Override
+ public void initializeTextureSize(BasicTexture texture, int format, int type) {
+ }
+ @Override
+ public void initializeTexture(BasicTexture texture, Bitmap bitmap) {
+ }
+ @Override
+ public void texSubImage2D(BasicTexture texture, int xOffset, int yOffset, Bitmap bitmap,
+ int format, int type) {
+ }
+ @Override
+ public int uploadBuffer(ByteBuffer buffer) {
+ return 0;
+ }
+ @Override
+ public int uploadBuffer(FloatBuffer buffer) {
+ return 0;
+ }
+ @Override
+ public void setBlending(Blending blending) {
+ }
+ @Override
+ public void enableStencil() {
+ }
+ @Override
+ public void disableStencil() {
+ }
+ @Override
+ public void clearStencilBuffer() {
+ }
+ @Override
+ public void updateStencil(boolean update) {
+ }
+ @Override
+ public void drawOnlyOutsideStencil(boolean onlyOutside) {
+ }
+ @Override
+ public void initialize(GL11 gl) {
+ }
}
diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasTest.java b/tests/src/com/android/gallery3d/ui/GLCanvasTest.java
index 72ccbfb96..ddbddad17 100644
--- a/tests/src/com/android/gallery3d/ui/GLCanvasTest.java
+++ b/tests/src/com/android/gallery3d/ui/GLCanvasTest.java
@@ -39,7 +39,8 @@ public class GLCanvasTest extends TestCase {
@SmallTest
public void testSetSize() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImpl(glStub);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(glStub);
canvas.setSize(100, 200);
canvas.setSize(1000, 100);
try {
@@ -57,7 +58,8 @@ public class GLCanvasTest extends TestCase {
private static class ClearBufferTest extends GLMock {
void run() {
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
assertEquals(0, mGLClearCalled);
canvas.clearBuffer();
assertEquals(GL10.GL_COLOR_BUFFER_BIT, mGLClearMask);
@@ -79,7 +81,8 @@ public class GLCanvasTest extends TestCase {
0x7F010101, 0xFEFEFDFC, 0x017F8081, 0x027F8081, 0x2ADE4C4D
};
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
canvas.setSize(400, 300);
// Test one color to make sure blend function is set.
assertEquals(0, mGLColorCalled);
@@ -107,7 +110,8 @@ public class GLCanvasTest extends TestCase {
@SmallTest
public void testSetGetMultiplyAlpha() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImpl(glStub);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(glStub);
canvas.setAlpha(1f);
assertEquals(1f, canvas.getAlpha());
@@ -146,7 +150,8 @@ public class GLCanvasTest extends TestCase {
private static class AlphaTest extends GLMock {
void run() {
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
canvas.setSize(400, 300);
assertEquals(0, mGLColorCalled);
@@ -188,7 +193,8 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
canvas.setSize(400, 300);
canvas.drawLine(2, 7, 1, 8, newColorPaint(0) /* color */);
assertTrue(mGLVertexArrayEnabled);
@@ -232,7 +238,8 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
canvas.setSize(400, 300);
canvas.fillRect(2, 7, 1, 8, 0 /* color */);
assertTrue(mGLVertexArrayEnabled);
@@ -294,7 +301,8 @@ public class GLCanvasTest extends TestCase {
}
void run() {
- GLCanvas canvas = new GLCanvasImpl(this);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(this);
canvas.setSize(40, 50);
int color = 0;
@@ -359,13 +367,6 @@ public class GLCanvasTest extends TestCase {
}
}
- @SmallTest
- public void testGetGLInstance() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImpl(glStub);
- assertSame(glStub, canvas.getGLInstance());
- }
-
private static void assertPremultipliedBlending(GLMock mock) {
assertTrue(mock.mGLBlendFuncCalled > 0);
assertTrue(mock.mGLBlendEnabled);
diff --git a/tests/src/com/android/gallery3d/ui/TextureTest.java b/tests/src/com/android/gallery3d/ui/TextureTest.java
index 36446b389..361bf7b84 100644
--- a/tests/src/com/android/gallery3d/ui/TextureTest.java
+++ b/tests/src/com/android/gallery3d/ui/TextureTest.java
@@ -48,6 +48,7 @@ public class TextureTest extends TestCase {
return GL11.GL_TEXTURE_2D;
}
+ @Override
public boolean isOpaque() {
mOpaqueCalled++;
return true;
@@ -61,7 +62,8 @@ public class TextureTest extends TestCase {
@SmallTest
public void testBasicTexture() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImpl(glStub);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(glStub);
MyBasicTexture texture = new MyBasicTexture(canvas, 47);
assertEquals(47, texture.getId());
@@ -81,7 +83,8 @@ public class TextureTest extends TestCase {
assertTrue(texture.isLoaded());
// For a different GL, it's not loaded.
- GLCanvas canvas2 = new GLCanvasImpl(new GLStub());
+ GLCanvas canvas2 = new GLCanvasImpl();
+ canvas2.initialize(glStub);
assertFalse(texture.isLoaded());
assertEquals(0, texture.mOnBindCalled);
@@ -135,7 +138,8 @@ public class TextureTest extends TestCase {
@SmallTest
public void testUploadedTexture() {
GL11 glStub = new GLStub();
- GLCanvas canvas = new GLCanvasImpl(glStub);
+ GLCanvas canvas = new GLCanvasImpl();
+ canvas.initialize(glStub);
MyUploadedTexture texture = new MyUploadedTexture();
// draw it and the bitmap should be fetched.
@@ -181,6 +185,7 @@ public class TextureTest extends TestCase {
return GL11.GL_TEXTURE_2D;
}
+ @Override
public boolean isOpaque() {
return true;
}