Skip to main content

Posts

Android : Sharing code and resources between UI and unit tests

As an Android developer you are already familiar with writing Unit and UI tests. This post is about "How to share the code and resources between your UI and unit tests?". I'd used "Appointments List" as an example scenario for this post. Existing Setup For UI testing, I'd have list of appointments API response in JSON format as "appointments.json" in res directory. The .json file is is converted to AppointmentsListResponse using JsonParser. androidTest/java/com/example/AppointmentScreenTest.java AppointmentsListResponse getFakeAppointmentsResponse() { InputStream in = getInstrumentation ().getContext() .getResources() .openRawResource(com.example.android.internal.test.R.raw.appointments); AppointmentsListResponse fakeResponse = new JsonParser(in).parseTo(AppointmentsListResponse. class ); } androidTest/ java/ com/example/JsonParser.java public class JsonParser String mStringToParse; private static Gson mGso
Recent posts

Android Studio Ninja Tip: Custom try/catch code template

As an Android Studio user, you should be familiar with the “ surround-with try-catch” functionality. Surround with try-catch When you use Ctrl+Alt+T (Linux) / Cmd+Alt+T (Mac) shortcut, the built-in try-catch generator auto generates a call to the printStackTrace() method of class Exception in the catch block. After this, we manually add some code to log the exception. e.g., Log.e(TAG, “Oops! something gone wrong”, e); As a power user, you may have used some or all of the following built-in Live templates: Live Templates You can save yourself the pain of these 5-keystrokes or repetitive typing or copy pasting the code by becoming a Ninja who uses a custom built-in try-catch template. Steps for customization Step-1 : Go to Android Studio Preferences | Editor | File and Code Templates Step-2:  Select Code | Catch Statement Body Step-3:  Replace the existing template from: ${EXCEPTION}.printStackTrace(); with: Log.e(getClass().getSimpleName(), "Ex

#! CrunchBang Post Installation Tips

Since I'm bored with a long time usage of Manjaro Linux( nearly 8 months) and minor problems like Huawei USB modem detection and update issues trigger me to look for another Linux Distro. I started my exploration with Distrowatch.com and reading couple of other distro reviews from various other blogs and finally came to conclusion to install a new lightweight Linux distribution called #! Crunchbang . Crunchbang Info(Source: Distrowatch.com ) OS Type:   Linux Based on:   Debian (Stable) Origin:   United Kingdom   Architecture:   i486 ,  i686 ,  x86_64 Desktop:   Openbox Category:   Desktop ,  Netbooks ,  Old Computers Status:   Active I'd started with downloading the latest 64-bit version of Crunchbang Linux 11 "Waldorf"   and used UNetbootin to create a live USB to install it in my machine. 1. #! Post Installation Script The nifty feature of Crunchbang I noticed on the startup is the Post installation script. The Post installation script provide

Manjaro XFCE Post Installation Tips and Tricks

It's nearly a year since my last post, a lot of things had happened in between, Placement preparation, couple of interviews, six month internship in Blackberry Platform at  Payoda Technologies   and finally completion of my studies. During this period a lot of distros had been released but I stayed with the stable Opensuse, but then I felt KDE version of opensuse is little bit heavy, which can be felt during both start-up and during normal day to day usage(say Eclipse+amarok+chrome) even with 4GB RAM and i3 Processor. I started my quest for "The best GNU/Linux OS" with distrowatch.com . Since I wanted a lighter distro but not certainly like Puppy/Tiny and no Ubuntu/Debian forks then by default I left with Arch. But the fear of  two earlier failed attempts to install Arch forced me to try arch fork than arch. Seeing  Manjaro   Linux description " Manjaro Linux is a desktop-oriented, user-friendly distribution based on Arch Linux " , I thought I would

Running Opensuse Under Proxy

If you are running Opensuse under proxy environment then every time if you are logged in means you need to manually Goto Yast2->Network Services->Proxy settings to configure your network. The following blog post describes how to set proxy in detail: www.unixmen.com/how-to-enable- proxy -on-opensuse.   In order to speed up the process, i had created a small script. #!/bin/bash echo "----------CONFIG PROXY--------------" echo "1.set proxy" echo "2.No proxy" echo "Enter the choice : " read choice case $choice in 1) echo "setting up Proxy" echo -e " PROXY_ENABLED=\"yes\" GOPHER_PROXY=\"\" NO_PROXY=\"localhost, 127.0.0.1\" HTTP_PROXY=\"http://172.16.35.90:8080\" HTTPS_PROXY=\"http://172.16.35.90:8080\" FTP_PROXY=\"http://172.16.35.90:8080\" " > /etc/sysconfig/proxy echo "bye..." ;; 2) echo "Unsetting the Prox

10 Things To do After Installing openSUSE 12.1

Here is a List of 10 Things which I had done After Installing openSUSE 12.1(KDE) 64bit. 1. Mounting a Windows Partition with +RWX Permission   a) Backup the fstab file before Modifying      ravi@linux:~>sudo cp -v /etc/fstab fstab_copy b) View Available Partitions      ravi@linux:~> cat /etc/fstab | grep "ntfs" /dev/disk/by-id/ata-WDC_WD5000BEVT-75A0RT0_WD-WXD1AC0Y1075-part3 /windows/D ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0 c)  Open the fstab file in super user mode and delete the fmask and dmask and set the umask value as '0026',          save the file and restart.     /dev/disk/by-id/ata-WDC_WD5000BEVT-75A0RT0_WD-WXD1AC0Y1075-part3 /windows/D           ntfs-3g    uid=1000,gid=100,umask=0026 0 0 2. Install the latest version of Chrome(64bit RPM)         https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm 3. Download and Install VLC Media Player         http://download.v

How to enable Scrolling in Opensuse11.4 ?

      I have recently installed Opensuse 11.4 KDE in Dell Inspiron N5010, the problem with it is Opensuse cannot support scrolling. Step 1  To make Scroll button Work install GSynaptics for OpenSuse.  GSynaptics is a GUI configuration tool for the Synaptics touchpad  driver of the X server. ravi@linux-2ezc:~>sudo zypper in gsyanptics Step 2         Edit the xorg.conf ravi@linux-2ezc:~> kdesu kwrite /etc/X11/xorg.conf.d/50-synaptics.conf Section "InputDevice" Driver "synaptics" Identifier "TouchPad" Option "SendCoreEvents" Option "Protocol" "auto-dev" Option "SHMConfig" "on" EndSection Section "InputClass" Identifier "touchpad catchall" Driver "synaptics" MatchIsTouchpad "on" MatchDevicePath "/dev/input/event*" Option "TapButton1" "