Skip to content

Commit 83b4d58

Browse files
authored
Merge pull request #98 from Tigerfriend1/refactor
Refactoring and Applying Design-Patterns
2 parents 2824c64 + c7bc222 commit 83b4d58

File tree

58 files changed

+2828
-1151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2828
-1151
lines changed

app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ android {
9595
outputFileName = "PhotonCamera-${versionName}${versionBuild}-${variant.name}.apk"
9696
}
9797
}
98+
testOptions {
99+
unitTests.returnDefaultValues = true
100+
}
98101
}
99102

100103
dependencies {
@@ -130,6 +133,12 @@ dependencies {
130133
//Use this lib to detect memory leaks when debugging
131134
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
132135
implementation 'com.quinn.hunter:hunter-debug-library:1.2.0'
136+
//For Testing
137+
testImplementation 'org.mockito:mockito-core:3.12.4'
138+
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
139+
implementation 'androidx.test.ext:junit:1.1.3'
140+
testImplementation 'junit:junit:4.13.1'
141+
androidTestImplementation 'org.testng:testng:7.1.0'
133142

134143
}
135144
repositories {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.particlesdevs.photoncamera.gallery.adapters;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.util.AttributeSet;
7+
import android.view.View;
8+
import android.widget.LinearLayout;
9+
import android.widget.TextView;
10+
11+
import androidx.appcompat.app.AppCompatActivity;
12+
import androidx.test.platform.app.InstrumentationRegistry;
13+
import androidx.test.ext.junit.runners.AndroidJUnit4;
14+
15+
import org.junit.After;
16+
import org.junit.Before;
17+
import org.junit.Test;
18+
import org.junit.runner.RunWith;
19+
20+
import static org.junit.Assert.*;
21+
22+
@RunWith(AndroidJUnit4.class)
23+
public class DepthPageTransformerTest {
24+
private DepthPageTransformer depthPageTransformer;
25+
private View view;
26+
27+
@Before
28+
public void setUp() throws Exception {
29+
depthPageTransformer = new DepthPageTransformer();
30+
view = new View(InstrumentationRegistry.getInstrumentation().getTargetContext());
31+
}
32+
33+
// [-infinity, -1)
34+
@Test
35+
public void testVEC1(){
36+
depthPageTransformer.transformPage(view, -2);
37+
assertEquals(0f, view.getAlpha());
38+
}
39+
40+
// [-1, 0]
41+
@Test
42+
public void testVEC2(){
43+
float expected = 1f;
44+
float[] positions = {-1, 0};
45+
for(float position : positions){
46+
depthPageTransformer.transformPage(view, position);
47+
assertEquals(expected, view.getAlpha());
48+
}
49+
}
50+
// (0, 1]
51+
@Test
52+
public void testVEC3(){
53+
float[] positions = {0.1f, 1f};
54+
float[] expected = {1-positions[0], 1-positions[1]};
55+
56+
for(int i=0; i< positions.length; i++){
57+
depthPageTransformer.transformPage(view, positions[i]);
58+
assertEquals(expected[i], view.getAlpha());
59+
}
60+
}
61+
// (1, +Infinity]
62+
@Test
63+
public void testVEC4(){
64+
float position = 2;
65+
depthPageTransformer.transformPage(view, position);
66+
assertEquals(0f, view.getAlpha());
67+
}
68+
69+
@After
70+
public void tearDown() throws Exception{
71+
depthPageTransformer = null;
72+
view = null;
73+
}
74+
75+
}

0 commit comments

Comments
 (0)