GSoC 4thWeek : An Enriching Experience

Deepak Prasad
4 min readJun 23, 2019

--

This week was full of learning and enriching experiences. The biggest blocker since the 3rd week was removed and eventually a the Provider’s Module (FETCH) was merged.

Milestones completed

Last week we saw how the LiveData’s onChange() method’s testing so much trouble. Let’s see how I got to solve it.

Testing LiveData’s onChange()

I figured out that onChange() is triggered on an asynchronous thread but testing runs on a single main thread. Therefore the following error always popped up.

java.lang.NullPointerException
at androidx.arch.core.executor.DefaultTaskExecutor.isMainThread(DefaultTaskExecutor.java:74)
at androidx.arch.core.executor.ArchTaskExecutor.isMainThread(ArchTaskExecutor.java:116)
at androidx.lifecycle.LiveData.assertMainThread(LiveData.java:442)

Found out that using the following rule will help in running the test on a single thread.

@Rule 
public InstantTaskExecutorRule taskExecutorRule = new InstantTaskExecutorRule();

To use this rule I needed testImplementation ‘android.arch.core:core-testing:1.1.1’ dependency as this helps in testing the Android’s new architecture components.

Found out some of the tests have broken. The Hamcrest Matchers did not work in the DBOpenHelperTest.java and this caused the build to fail.

Figured that the Mockito version needs to be updated with PowerMock too. Proceed to change the Mockito to version 2 and PowerMock to version 1.7. Changed the Hamcrest Matchers with Mockito.anyString().

What did it cost?

Source: Imgur

The build passed but every single test cases failed to run. There were many different errors that caused a nightmare and some sleepless nights. I knew I had messed up. In that case,

Source: makeameme.org

I restored the older versions and researched more. So these were the things that needed to be done:

  1. Upgraded Mockito core to 2.8.9
  2. Upgraded Powermock to Powermock2 : 2.0.2
  3. Upgraded JUnit4 to 2.0.2
  4. Added Android architecture testing library
  5. Added Instant Task Executor rule to LiveData’s testing classes
  6. Replaced Hamcrest Matchers with Mockito.anyString()
  7. Added Mockito.lenient() to all the Stubbings

The last action of adding Mockito.lenient() tells Mockito to ignore those stubbings that haven’t been used in testing. Generally we should remove those stubbings but finding such stubbings in such a large project is very difficult.

Find the PR here.

Adding an expandable FAB

An Expandable Floating Action Button was added to the Patient Details. Also the pending work of adding a Material layout for Patient’s details were added. The margins and layout of CardView was changed to make them consistent throughout the app.

The Expandable FAB was created from scratch without using any external libraries as most of the libraries I encountered were outdated and were designed on older Support Versions.

Also I learnt how to add animations to Vector Drawables and to slide a layout to a particular distance creating a smooth transition. Also learnt how to get Resources from a static Context.

Find the PR here.

Adding Delete to Provider’s Module

I will be adding the Delete and Edit options in the Provider’s Module. I will be using Swipe to Reveal Options menu in Recycler view.

I have finished coding the Delete option but am not able to delete the Provider. Also tried deleting the Provider form the Demo website but wasn’t able to do so.

Need to work on it more and know where the crux of the problems is.

Target for next week

Next week will have the First Round of Evaluations. Apart from that the things I will be focussing on will be:

  1. Delete feature for Providers
  2. A layout for Creating/Editing Providers
  3. Figure out how to add a Dark Theme

I have been figuring out how to add the Dark Theme in the app but couldn’t because most of the views are custom defined. I will definitely learn a lot by adding dark theme to the custom views.

--

--