CloudServices/NativeSync: Difference between revisions

Jump to navigation Jump to search
Line 24: Line 24:
  hw.ramSize=256
  hw.ramSize=256


{{note|Target (in the example above, 'android-10') probably needs to match build specified in .mozconfig (see Building Fennec Native below).}}
{{note|Target (in the example above, <tt>android-10</tt>) probably needs to match build specified in .mozconfig (see Building Fennec Native below).}}


* to launch:
* to launch:
Line 40: Line 40:
== Running everything ==
== Running everything ==


You'll be wanting to run test-android-sync:
The main <tt>android-sync</tt> source repository is hosted on github:


* https://github.com/mozilla-services/test-android-sync
https://github.com/mozilla-services/android-sync


This depends on the android-sync project, as described in [http://developer.android.com/guide/topics/testing/testing_android.html the Android testing docs]:
Try


* https://github.com/mozilla-services/android-sync
git clone git@github.com:mozilla-services/android-sync.git


=== android-sync dependencies ===
=== android-sync dependencies ===
Line 60: Line 60:
* JUnit 4.1.
* JUnit 4.1.
* org.simpleframework.simple, for HTTP testing.
* org.simpleframework.simple, for HTTP testing.
* Tiny “un-stub” packages for android.util.Log and android.util.Base64. These live on GitHub, and must be built and installed.
* Tiny “un-stub” packages for android.util.Log, android.util.Base64, and android.content.SharedPreferences.
 
These live on github, and must be built and installed.
 
** https://github.com/rnewman/base64-unstub
** https://github.com/rnewman/base64-unstub
** https://github.com/rnewman/log-unstub
** https://github.com/rnewman/log-unstub
** https://github.com/rnewman/sharedpreferences-stub


=== sync-crypto dependencies ===
=== sync-crypto dependencies ===


sync-crypto relies on Apache commons-codec 1.5, which includes Base32. The Android system libraries include the 8-year-old version 1.2. As a result, sync-crypto is packaged as an assembly jar (aka über jar). Simply run <tt>build.sh</tt> to instruct Maven to do the right thing.
sync-crypto relies on Apache commons-codec 1.5, which includes Base32. The Android system libraries include the 8-year-old version 1.2. As a result, sync-crypto is packaged as an assembly jar (aka über jar).
 
An up-to-date version is checked in to the <tt>external</tt> directory in <tt>android-sync</tt>, with the <tt>mvnify</tt> script in that directory taking care of installing it in your local repository.


=== What you need to do ===
=== What you need to do ===
Line 74: Line 76:
  git clone https://github.com/rnewman/base64-unstub
  git clone https://github.com/rnewman/base64-unstub
  git clone https://github.com/rnewman/log-unstub
  git clone https://github.com/rnewman/log-unstub
git clone https://github.com/rnewman/sharedpreferences-stub
  git clone https://github.com/mozilla-services/android-sync
  git clone https://github.com/mozilla-services/android-sync
git clone https://github.com/mozilla-services/test-android-sync
  pushd base64-unstub;         mvn install; popd
  pushd base64-unstub; mvn install; popd
  pushd log-unstub;             mvn install; popd
  pushd log-unstub;   mvn install; popd
  pushd sharedpreferences-stub; mvn install; popd
  pushd android-sync/external; ./mvnify; popd (Note: mvnify may not be available, in which case, skip this step)
  pushd android-sync
  pushd android-sync
  ./deps.sh (Note: mvn assembly:assembly may fail, however, it is still ok to proceed.)
git checkout develop
  ./preprocess.sh
  mvn test
  mvn test
To do real Android development and testing, you need to import both android-sync and test-android-sync as projects in Eclipse with the ADT installed.


Note that both android-sync and sync-crypto have JUnit 4 tests that run in both Eclipse and Maven. android-sync also provides functionality to test-android-sync, which includes Android JUnit 3 tests for activity and store testing. This is to avoid the mammoth annoyance of testing in a VM without introducing robolectric.
{{note|<tt>mvn assembly:assembly</tt> may fail, however, it is still ok to proceed.}}
 
To do real Android development and testing, you need to import android-sync as a project in Eclipse with the ADT installed.
 
Note that both android-sync and sync-crypto have JUnit 4 tests that run in both Eclipse and Maven. The subdirectory android-sync/test includes Android JUnit 3 tests for activity and store testing. This is to avoid the mammoth annoyance of testing in a VM without introducing robolectric.


=== Running Fennec ===
=== Running Fennec ===
Line 116: Line 121:
* Install Eclipse and the SDK plugin, as described in the Android SDK page.
* Install Eclipse and the SDK plugin, as described in the Android SDK page.
* Correct formatting: <tt>Preferences > Java > Code style > Formatter > Edit...</tt>, set profile name to <tt>Mozilla</tt>, set <tt>Tab policy</tt> to <tt>Spaces only</tt> change both <tt>Indentation size</tt> and <tt>Tab size</tt> to 2, and check <tt>Align fields in columns</tt>.
* Correct formatting: <tt>Preferences > Java > Code style > Formatter > Edit...</tt>, set profile name to <tt>Mozilla</tt>, set <tt>Tab policy</tt> to <tt>Spaces only</tt> change both <tt>Indentation size</tt> and <tt>Tab size</tt> to 2, and check <tt>Align fields in columns</tt>.
* Run these commands in both your <tt>android-sync</tt> and <tt>test-android-sync</tt> git repository directories (don't forget to checkout the ''develop'' branch in both repositories):
* Run these commands in your <tt>android-sync</tt> git repository directory (don't forget to checkout the <tt>develop</tt> branch):


  mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
  mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
  mvn -DdownloadJavadocs=true -DdownloadSources=true eclipse:eclipse
  mvn -DdownloadJavadocs=true -DdownloadSources=true eclipse:eclipse


* Install the project and classpath files (again in both git repository directores), making sure to update the paths where necessary in all files:
* Install the project and classpath files (again in your git repository directory), making sure to update the paths where necessary in both files:


  cp example.project .project
  cp example.project .project
  cp example.classpath .classpath
  cp example.classpath .classpath


* Open Eclipse, choose <tt>File > Import... > General > Existing Projects into Workspace</tt>, and specify each git repository directory in turn.
* Open Eclipse, choose <tt>File > Import... > General > Existing Projects into Workspace</tt>, and specify your git repository directory.


{{note|You may need to set <tt>M2_REPO</tt> (for example, as described at [http://www.mkyong.com/maven/how-to-configure-m2_repo-variable-in-eclipse-ide/]) to something like <tt>$HOME/.m2/repository</tt>.}}
{{note|You may need to set <tt>M2_REPO</tt> (for example, as described at [http://www.mkyong.com/maven/how-to-configure-m2_repo-variable-in-eclipse-ide/]) to something like <tt>$HOME/.m2/repository</tt>.}}


==== To run the android-sync test suite under Eclipse ====
==== To run the unit test suite under Eclipse ====


* First configure the test suite launcher, under <tt>Preferences > Run/Debug > Launching > Default Launchers</tt>.  Set the Debug and Run launchers to <tt>Android JUnit Test Launcher</tt>.
* First configure the test suite launcher, under <tt>Preferences > Run/Debug > Launching > Default Launchers</tt>.  Set the Debug and Run launchers to <tt>Android JUnit Test Launcher</tt>.
* Select the <tt>android-sync</tt> project and execute <tt>Run > Run As ... > JUnit Test</tt>.
* Select the <tt>android-sync</tt> project and execute <tt>Run > Run As ... > JUnit Test</tt>.


==== To run the test-android-sync test suite under Eclipse ====
==== To run the integration test suite under Eclipse ====
 
* Add the <tt>test</tt> subdirectory as a sub-project using <tt>File > Import > Existing project</tt>.
 
* Refresh and clean everything.


* Select the <tt>android-sync-test</tt> project (yes, the name is different from the git repository) and execute <tt>Run > Run As ... > Android JUnit Test</tt>.
* Select the <tt>test</tt> project and execute <tt>Run > Run As ... > Android JUnit Test</tt>.


== Development ==
== Development ==
Line 147: Line 156:
We don't quite follow the [[Fennec/NativeUI/CodingStyle]]. See also [http://source.android.com/source/code-style.html the Android coding style].
We don't quite follow the [[Fennec/NativeUI/CodingStyle]]. See also [http://source.android.com/source/code-style.html the Android coding style].


=== Running test code coverage ===
=== Running unit test code coverage ===


To see the current test code coverage (using the Maven plugin integrating Cobertura), from the <tt>android-sync</tt> directory run
To see the current unit test code coverage (using the Maven plugin integrating Cobertura), from the <tt>android-sync</tt> directory run


  mvn cobertura:cobertura
  mvn cobertura:cobertura
Line 158: Line 167:


and click on <tt>org.mozilla.gecko</tt>.
and click on <tt>org.mozilla.gecko</tt>.
{{note|At this time, you can't see the current integration test code coverage.}}


== Security ==
== Security ==
Line 179: Line 190:
     <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
     <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
     <uses-permission android:name="android.permission.READ_SYNC_STATS" />
     <uses-permission android:name="android.permission.READ_SYNC_STATS" />
     <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
     <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
Confirmed users
355

edits

Navigation menu