Open
Conversation
Added instrumented tests for MainActivity Added required dependencies for Mockito and updated other dependencies.
Added login data changed test Added invalid username error generation test
discospiff
reviewed
Apr 2, 2023
Comment on lines
-40
to
+54
| implementation 'androidx.core:core-ktx:1.7.0' | ||
| implementation 'androidx.core:core-ktx:1.9.0' | ||
| implementation 'androidx.appcompat:appcompat:1.6.1' | ||
| implementation 'com.google.android.material:material:1.8.0' | ||
| implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
| implementation 'androidx.core:core-ktx:+' | ||
| implementation 'androidx.annotation:annotation:1.3.0' | ||
| implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1' | ||
| implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' | ||
| implementation 'androidx.core:core-ktx:1.9.0' | ||
| implementation 'androidx.annotation:annotation:1.6.0' | ||
| implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' | ||
| implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' | ||
| testImplementation 'junit:junit:4.13.2' | ||
| androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
| testImplementation 'junit:junit:4.13.2' | ||
| testImplementation 'org.mockito:mockito-core:3.12.4' | ||
| testImplementation 'androidx.arch.core:core-testing:2.2.0' | ||
| testImplementation 'org.mockito:mockito-inline:2.13.0' |
There was a problem hiding this comment.
Careful when updating dependencies in an Android project. Many times, dependencies have dependencies on each other. Upgrading one can create a game of Whack-A-Mole.
discospiff
reviewed
Apr 2, 2023
Comment on lines
+31
to
+52
| class MainActivityTest { | ||
| @Test | ||
| fun onClick_drawButtonBlack() { | ||
| ActivityScenario.launch(MainActivity::class.java) | ||
| onView(withId(draw)).perform(click()) | ||
| assert(DrawView.currentColor == Color.BLACK) | ||
| } | ||
| @Test | ||
| fun onClick_eraserButtonWhite(){ | ||
| ActivityScenario.launch(MainActivity::class.java) | ||
| onView(withId(eraser)).perform(click()) | ||
| assert(DrawView.currentColor == Color.WHITE) | ||
| } | ||
| @Test | ||
| fun onClick_deleteButtonWorks(){ | ||
| ActivityScenario.launch(MainActivity::class.java) | ||
| DrawView.pathList.add(Path()) | ||
| DrawView.colorList.add(Color.BLACK) | ||
| onView(withId(delete)).perform(click()) | ||
| assert(DrawView.pathList.isEmpty()) | ||
| assert(DrawView.colorList.isEmpty()) | ||
| } |
There was a problem hiding this comment.
Better unit test coverage is always a good idea.
Be cautious with UI tests, as they tend to be brittle. One small UI change can invalidate an entire series of tests.
discospiff
reviewed
Apr 2, 2023
Comment on lines
+22
to
+25
| fun isValidEmail(email: String): Boolean { | ||
| val emailRegex = Regex("^\\w+([.-]?\\w+)*@\\w+([.-]?\\w+)*(\\.\\w{2,})+\$") | ||
| return email.matches(emailRegex) | ||
| } |
There was a problem hiding this comment.
Regex are a great way to validate user input!
|
Good suggestions here.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Analysis of the program: RoomRemix2 is an interior design program that allows users to visually construct a rooms layout by adding, removing, and modify furniture in order to plan out functional living spaces.
Was the program available in UC GitHub on time? : Yes
Is the program documented/commented well enough for you to understand?: Yes
Does the program compile?: Yes
Rationale behind your changes: I noticed when logging into the application that the username prompt specifically asks for email for registration, but any string could be inputted and was accepted as the username. If the username is meant to be email specific then inputted strings should be checked for valid email format. I added a regular expression to the login function that checks for valid email format. I also added a test that checks if login data change is properly registered, and a test that checks if invalid username generates a username error. With these changes it will be possible to modify the username in login main activity so that only email formatted strings are accepted as a username, and will throw appropriate errors if the username is not an email. This will help keep the UI prompt consistent with accepted changed data inputs that are added to the database and help ensure that only emails are accepted as the username input for registration.
Reference:
https://developermemos.com/posts/validating-email-addresses-kotlin
https://www.stackhawk.com/blog/guide-to-security-in-kotlin/
Links to my Sprint 2 commits:
jakeFarrish/MedMapper@bdb9c17
jakeFarrish/MedMapper@911a129
jakeFarrish/MedMapper@f7a236a
jakeFarrish/MedMapper@9494fe0
Three specific technical concepts I learned:
I learned about regular expressions, which are good tools to use for pattern matching and text manipulation. Regular expressions can be used to make sure that string inputs match specific criteria, which can be useful when dealing with username and password formatting.
I learned about Observer, an interface used to observe changes in a LiveData object. I implemented observer to view changes to the LiveData username/password objects in the unit tests that were added.
I learned more about data binding, in this case login activity binding of UI components to the corresponding LoginActivity variables used in the LoginActivity logic.