Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb undo redo #220

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
70d8844
Add undo and redo
Gondolav Jan 23, 2020
4443f62
Fix undo/redo bug
LudoHoff Jan 23, 2020
a5dff36
Delete eraser button
LudoHoff Jan 24, 2020
c315435
Fix undo/redo bug
LudoHoff Jan 24, 2020
d311937
Merge branch 'master' into fb-undo-redo
Gondolav Jan 24, 2020
d6d8dd5
Add undo/redo textures and remove eraser code
LudoHoff Jan 24, 2020
ef8ae48
Merge branch 'fb-undo-redo' of https://github.com/Claudio5/SDP into f…
LudoHoff Jan 24, 2020
6541071
Remove default colors from shop and tests
Gondolav Jan 24, 2020
4b4b28e
Add default colors to DrawingActivity
Gondolav Jan 24, 2020
d299700
Merge branch 'fb-undo-redo' of github.com:gyrodraw/GyroDraw into fb-u…
Gondolav Jan 24, 2020
cf71f53
Fix default colors bug
Gondolav Jan 24, 2020
80b2317
Fix drawing bug and tests
LudoHoff Jan 24, 2020
8eef667
Fix mockito dependency issue
Gondolav Jan 24, 2020
b8f123c
Fix tests imports
Gondolav Jan 24, 2020
5665849
Merge branch 'fb-undo-redo' of github.com:gyrodraw/GyroDraw into fb-u…
Gondolav Jan 24, 2020
ea36429
Try to fix .travis.yml
Gondolav Jan 24, 2020
349b405
Try to fix travis
Gondolav Jan 24, 2020
498c5e3
Fix dependencies and travis
Gondolav Jan 24, 2020
04b7f68
Sort drawing colors by hue
LudoHoff Jan 24, 2020
459c727
Merge branch 'fb-undo-redo' of https://github.com/Claudio5/SDP into f…
LudoHoff Jan 24, 2020
61b65ce
Update gradle and functions
Gondolav Jan 24, 2020
93bbf99
Merge branch 'fb-undo-redo' of github.com:gyrodraw/GyroDraw into fb-u…
Gondolav Jan 24, 2020
11115be
Revert Firebase functions
Gondolav Jan 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ android:
- 'google-gdk-license-.+'
before_install:
- yes | sdkmanager "platforms;android-28"
​- yes | sdkmanager --install "build-tools;28.0.3"​
​- yes | sdkmanager "build-tools;28.0.3"​
before_script:
- yes | sdkmanager "platforms;android-28"
​- yes | sdkmanager --install "build-tools;28.0.3"​
# Set up Code Climate test reporter
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
Expand Down
38 changes: 29 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,46 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'org.mockito:mockito-android:2.7.22'
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-functions:19.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
implementation 'com.facebook.android:facebook-share:4.42.0'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.7.22'
androidTestImplementation 'org.mockito:mockito-android:2.7.22'
androidTestImplementation 'org.mockito:mockito-android:3.2.4'
testImplementation 'org.mockito:mockito-core:3.2.4'
implementation 'org.apache.commons:commons-lang3:3.5'
androidTestImplementation 'androidx.test:core:1.2.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'

// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
androidTestImplementation 'com.google.truth:truth:0.42'

// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0'

// The following Espresso dependency can be either "implementation"
// or "androidTestImplementation", depending on whether you want the
// dependency to appear on your APK's compile classpath or the test APK
// classpath.
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.2.0'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
package ch.epfl.sweng.GyroDraw.game.drawing;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static ch.epfl.sweng.GyroDraw.game.drawing.DrawingActivity.CURR_WIDTH;
import static ch.epfl.sweng.GyroDraw.game.drawing.DrawingActivity.MIN_WIDTH;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import android.graphics.Color;
import android.os.SystemClock;
import android.widget.SeekBar;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import android.widget.SeekBar;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import ch.epfl.sweng.GyroDraw.R;
import ch.epfl.sweng.GyroDraw.auth.Account;
import ch.epfl.sweng.GyroDraw.shop.ColorsShop;
import ch.epfl.sweng.GyroDraw.shop.ShopItem;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static ch.epfl.sweng.GyroDraw.game.drawing.DrawingActivity.CURR_WIDTH;
import static ch.epfl.sweng.GyroDraw.game.drawing.DrawingActivity.MIN_WIDTH;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class DrawingOfflineActivityNoItemsTest {

Expand All @@ -38,9 +36,9 @@ public void init() {
paintView = activityRule.getActivity().findViewById(R.id.paintView);
paintView.isDrawing = true;
Account.getInstance(activityRule.getActivity().getApplicationContext())
.updateItemsBought(new ShopItem(ColorsShop.BLUE, 200));
.updateItemsBought(new ShopItem(ColorsShop.CYAN, 200));
Account.getInstance(activityRule.getActivity().getApplicationContext())
.updateItemsBought(new ShopItem(ColorsShop.RED, 100));
.updateItemsBought(new ShopItem(ColorsShop.PURPLE, 100));
}

@Test
Expand All @@ -65,39 +63,25 @@ public void testBlackButton() {
@Test
public void testPencilTool() {
paintView.isDrawing = false;
onView(ViewMatchers.withId(R.id.eraserButton)).perform(click());
onView(ViewMatchers.withId(R.id.bucketButton)).perform(click());
onView(ViewMatchers.withId(R.id.pencilButton)).perform(click());
onView(ViewMatchers.withId(R.id.paintView)).perform(click());
assertThat(paintView.getBitmap().getPixel(paintView.getCircleX(), paintView.getCircleY()),
is(Color.WHITE));
}

@Test
public void testEraserTool() {
paintView.isDrawing = false;
onView(ViewMatchers.withId(R.id.eraserButton)).perform(click());
onView(ViewMatchers.withId(R.id.paintView)).perform(click());
assertThat(paintView.getBitmap().getPixel(paintView.getCircleX(), paintView.getCircleY()),
is(Color.WHITE));
}

@Test
public void testToolsWhileDrawing() {
paintView.isDrawing = true;
paintView.setPencil();
assertThat(paintView.isDrawing, is(false));

paintView.isDrawing = true;
paintView.setEraser();
assertThat(paintView.isDrawing, is(false));

paintView.isDrawing = true;
paintView.setBucket();
assertThat(paintView.isDrawing, is(false));
}



@Test
public void testBucketTool() {
paintView.isDrawing = false;
Expand Down Expand Up @@ -125,4 +109,4 @@ public void testChangeBrushWidth() {
SystemClock.sleep(2000);
assertThat(paintView.getDrawWidth(), is(initWidth));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package ch.epfl.sweng.GyroDraw.game.drawing;

import static androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertThat;

import android.os.SystemClock;
import androidx.test.rule.ActivityTestRule;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.util.Map;

import androidx.test.rule.ActivityTestRule;
import ch.epfl.sweng.GyroDraw.R;
import ch.epfl.sweng.GyroDraw.auth.Account;
import ch.epfl.sweng.GyroDraw.game.drawing.items.BumpingItem;
Expand All @@ -21,14 +22,10 @@
import ch.epfl.sweng.GyroDraw.game.drawing.items.SwapAxisItem;
import ch.epfl.sweng.GyroDraw.shop.ColorsShop;
import ch.epfl.sweng.GyroDraw.shop.ShopItem;

import static androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertThat;
import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class DrawingOfflineActivityWithItemsTest {

Expand Down Expand Up @@ -59,8 +56,8 @@ public void init() {
account.setUserId(USER_ID);
account.setUsername(USERNAME);
account.setEmail(EMAIL);
account.updateItemsBought(new ShopItem(ColorsShop.BLUE, 200));
account.updateItemsBought(new ShopItem(ColorsShop.RED, 100));
account.updateItemsBought(new ShopItem(ColorsShop.CYAN, 200));
account.updateItemsBought(new ShopItem(ColorsShop.PURPLE, 100));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package ch.epfl.sweng.GyroDraw.game.drawing;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static ch.epfl.sweng.GyroDraw.game.LoadingScreenActivity.ROOM_ID;
import static ch.epfl.sweng.GyroDraw.game.WaitingPageActivity.WINNING_WORD;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.when;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand All @@ -10,40 +23,23 @@
import android.os.SystemClock;
import androidx.test.espresso.intent.Intents;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.google.firebase.database.DataSnapshot;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import androidx.test.rule.ActivityTestRule;
import ch.epfl.sweng.GyroDraw.R;
import ch.epfl.sweng.GyroDraw.auth.Account;
import ch.epfl.sweng.GyroDraw.game.VotingPageActivity;
import ch.epfl.sweng.GyroDraw.localDatabase.LocalDbForImages;
import ch.epfl.sweng.GyroDraw.localDatabase.LocalDbHandlerForImages;
import ch.epfl.sweng.GyroDraw.shop.ColorsShop;
import ch.epfl.sweng.GyroDraw.shop.ShopItem;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static ch.epfl.sweng.GyroDraw.game.LoadingScreenActivity.ROOM_ID;
import static ch.epfl.sweng.GyroDraw.game.WaitingPageActivity.WINNING_WORD;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.when;
import com.google.firebase.database.DataSnapshot;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;

@RunWith(AndroidJUnit4.class)
public class DrawingOnlineActivityTest {
Expand Down Expand Up @@ -74,9 +70,9 @@ public void init() {
paintView.isDrawing = true;
dataSnapshotMock = Mockito.mock(DataSnapshot.class);
Account.getInstance(activityRule.getActivity())
.updateItemsBought(new ShopItem(ColorsShop.BLUE, 200));
.updateItemsBought(new ShopItem(ColorsShop.CYAN, 200));
Account.getInstance(activityRule.getActivity())
.updateItemsBought(new ShopItem(ColorsShop.RED, 100));
.updateItemsBought(new ShopItem(ColorsShop.PURPLE, 100));
}

@Test
Expand Down Expand Up @@ -167,7 +163,7 @@ public static Bitmap initializedBitmap() {
/**
* Assert if the two bitmaps have the same pixels.
*
* @param bitmap the first bitmap
* @param bitmap the first bitmap
* @param newBitmap the second bitmap
*/
public static void bitmapEqualsNewBitmap(Bitmap bitmap, Bitmap newBitmap) {
Expand All @@ -181,7 +177,7 @@ public static void bitmapEqualsNewBitmap(Bitmap bitmap, Bitmap newBitmap) {
/**
* Compress a bitmap to the given quality.
*
* @param bitmap the given bitmap
* @param bitmap the given bitmap
* @param quality the given quality
* @return the compressed bitmap
*/
Expand Down
Loading