| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 package org.webrtc; | 28 package org.webrtc; |
| 29 | 29 |
| 30 import android.graphics.Point; | 30 import android.graphics.Point; |
| 31 import android.opengl.EGL14; | |
| 32 import android.test.ActivityTestCase; | 31 import android.test.ActivityTestCase; |
| 33 import android.test.suitebuilder.annotation.MediumTest; | 32 import android.test.suitebuilder.annotation.MediumTest; |
| 34 import android.view.View.MeasureSpec; | 33 import android.view.View.MeasureSpec; |
| 35 | 34 |
| 36 import java.nio.ByteBuffer; | 35 import java.nio.ByteBuffer; |
| 37 import java.util.Arrays; | 36 import java.util.Arrays; |
| 38 import java.util.List; | 37 import java.util.List; |
| 39 | 38 |
| 39 import javax.microedition.khronos.egl.EGL10; |
| 40 |
| 40 public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase { | 41 public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase { |
| 41 /** | 42 /** |
| 42 * List with all possible scaling types. | 43 * List with all possible scaling types. |
| 43 */ | 44 */ |
| 44 private static final List<RendererCommon.ScalingType> scalingTypes = Arrays.as
List( | 45 private static final List<RendererCommon.ScalingType> scalingTypes = Arrays.as
List( |
| 45 RendererCommon.ScalingType.SCALE_ASPECT_FIT, | 46 RendererCommon.ScalingType.SCALE_ASPECT_FIT, |
| 46 RendererCommon.ScalingType.SCALE_ASPECT_FILL, | 47 RendererCommon.ScalingType.SCALE_ASPECT_FILL, |
| 47 RendererCommon.ScalingType.SCALE_ASPECT_BALANCED); | 48 RendererCommon.ScalingType.SCALE_ASPECT_BALANCED); |
| 48 | 49 |
| 49 /** | 50 /** |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, | 104 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, |
| 104 0, 0, zeroMeasureSize, zeroMeasureSize); | 105 0, 0, zeroMeasureSize, zeroMeasureSize); |
| 105 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, | 106 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, |
| 106 1280, 720, | 107 1280, 720, |
| 107 MeasureSpec.makeMeasureSpec(1280, measureSpecMode), | 108 MeasureSpec.makeMeasureSpec(1280, measureSpecMode), |
| 108 MeasureSpec.makeMeasureSpec(720, measureSpecMode)); | 109 MeasureSpec.makeMeasureSpec(720, measureSpecMode)); |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 // Test behaviour after SurfaceViewRenderer.init() is called, but still no fr
ame. | 113 // Test behaviour after SurfaceViewRenderer.init() is called, but still no fr
ame. |
| 113 surfaceViewRenderer.init(EGL14.EGL_NO_CONTEXT, null); | 114 surfaceViewRenderer.init(EGL10.EGL_NO_CONTEXT, null); |
| 114 for (RendererCommon.ScalingType scalingType : scalingTypes) { | 115 for (RendererCommon.ScalingType scalingType : scalingTypes) { |
| 115 for (int measureSpecMode : measureSpecModes) { | 116 for (int measureSpecMode : measureSpecModes) { |
| 116 final int zeroMeasureSize = MeasureSpec.makeMeasureSpec(0, measureSpecMo
de); | 117 final int zeroMeasureSize = MeasureSpec.makeMeasureSpec(0, measureSpecMo
de); |
| 117 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, | 118 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, |
| 118 0, 0, zeroMeasureSize, zeroMeasureSize); | 119 0, 0, zeroMeasureSize, zeroMeasureSize); |
| 119 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, | 120 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, |
| 120 1280, 720, | 121 1280, 720, |
| 121 MeasureSpec.makeMeasureSpec(1280, measureSpecMode), | 122 MeasureSpec.makeMeasureSpec(1280, measureSpecMode), |
| 122 MeasureSpec.makeMeasureSpec(720, measureSpecMode)); | 123 MeasureSpec.makeMeasureSpec(720, measureSpecMode)); |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 | 126 |
| 126 surfaceViewRenderer.release(); | 127 surfaceViewRenderer.release(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 /** | 130 /** |
| 130 * Test how SurfaceViewRenderer.onMeasure() behaves with a 1280x720 frame. | 131 * Test how SurfaceViewRenderer.onMeasure() behaves with a 1280x720 frame. |
| 131 */ | 132 */ |
| 132 @MediumTest | 133 @MediumTest |
| 133 public void testFrame1280x720() { | 134 public void testFrame1280x720() { |
| 134 final SurfaceViewRenderer surfaceViewRenderer = | 135 final SurfaceViewRenderer surfaceViewRenderer = |
| 135 new SurfaceViewRenderer(getInstrumentation().getContext()); | 136 new SurfaceViewRenderer(getInstrumentation().getContext()); |
| 136 surfaceViewRenderer.init(EGL14.EGL_NO_CONTEXT, null); | 137 surfaceViewRenderer.init(EGL10.EGL_NO_CONTEXT, null); |
| 137 | 138 |
| 138 // Test different rotation degress, but same rotated size. | 139 // Test different rotation degress, but same rotated size. |
| 139 for (int rotationDegree : new int[] {0, 90, 180, 270}) { | 140 for (int rotationDegree : new int[] {0, 90, 180, 270}) { |
| 140 final int rotatedWidth = 1280; | 141 final int rotatedWidth = 1280; |
| 141 final int rotatedHeight = 720; | 142 final int rotatedHeight = 720; |
| 142 final int unrotatedWidth = (rotationDegree % 180 == 0 ? rotatedWidth : rot
atedHeight); | 143 final int unrotatedWidth = (rotationDegree % 180 == 0 ? rotatedWidth : rot
atedHeight); |
| 143 final int unrotatedHeight = (rotationDegree % 180 == 0 ? rotatedHeight : r
otatedWidth); | 144 final int unrotatedHeight = (rotationDegree % 180 == 0 ? rotatedHeight : r
otatedWidth); |
| 144 final VideoRenderer.I420Frame frame = | 145 final VideoRenderer.I420Frame frame = |
| 145 createFrame(unrotatedWidth, unrotatedHeight, rotationDegree); | 146 createFrame(unrotatedWidth, unrotatedHeight, rotationDegree); |
| 146 assertEquals(rotatedWidth, frame.rotatedWidth()); | 147 assertEquals(rotatedWidth, frame.rotatedWidth()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 for (RendererCommon.ScalingType scalingType : scalingTypes) { | 208 for (RendererCommon.ScalingType scalingType : scalingTypes) { |
| 208 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, | 209 assertMeasuredSize(surfaceViewRenderer, scalingType, frameDimensions, |
| 209 720, 1280, widthSpec, heightSpec); | 210 720, 1280, widthSpec, heightSpec); |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 } | 213 } |
| 213 | 214 |
| 214 surfaceViewRenderer.release(); | 215 surfaceViewRenderer.release(); |
| 215 } | 216 } |
| 216 } | 217 } |
| OLD | NEW |