Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge test-app into test; fix some 64/32-bit problems.

  • Loading branch information...
commit 24f93af2d75366fd1dccdfda287fd1f552afcd96 1 parent 067990e
Daniel Solano Gómez sattvik authored
Showing with 110 additions and 229 deletions.
  1. +13 −14 build-support/clojure-compile.clj
  2. +6 −0 src/clojure/neko/_protocols/resolvable.clj
  3. +6 −0 src/clojure/neko/find_view.clj
  4. +0 −21 test-app/AndroidManifest.xml
  5. +0 −19 test-app/ant.properties
  6. +0 −85 test-app/build.xml
  7. +0 −20 test-app/proguard-project.txt
  8. +0 −40 test-app/proguard.cfg
  9. +0 −11 test-app/project.properties
  10. +12 −2 test/AndroidManifest.xml
  11. +0 −1  test/ant.properties
  12. +57 −0 test/build.xml
  13. 0  {test-app → test}/res/drawable-hdpi/icon.png
  14. 0  {test-app → test}/res/drawable-ldpi/icon.png
  15. 0  {test-app → test}/res/drawable-mdpi/icon.png
  16. 0  {test-app → test}/res/layout/main.xml
  17. 0  {test-app → test}/res/values/strings.xml
  18. +2 −2 ...-app/src/clojure/com/sattvik/neko/test_app → test/src/clojure/com/sattvik/neko/tests}/TestActivity.clj
  19. +3 −3 test/src/clojure/neko/activity_test.clj
  20. +5 −5 test/src/clojure/neko/context_test.clj
  21. +1 −1  test/src/clojure/neko/dialog/alert_test.clj
  22. +2 −2 test/src/clojure/neko/find_view_test.clj
  23. +2 −2 test/src/clojure/neko/test_utils.clj
  24. +1 −1  test/src/clojure/neko/threading_test.clj
27 build-support/clojure-compile.clj
View
@@ -53,21 +53,20 @@
(compile ns)
(swap! compiled-ns conj ns)
true
- (catch clojure.lang.Compiler$CompilerException e
+ (catch Exception e
(let [msg (.getMessage e)
- cnfe-pattern #"^java\.lang\.ClassNotFoundException: ([a-zA-z0-9-_.]+)(, compiling:| )\(.*:\d+\)$"]
- (let [matches (re-matches cnfe-pattern msg)]
- (if matches
- (let [not-found-ns (symbol (matches 1))]
- (println (format "Dependency failure detected, will try to compile %s." not-found-ns))
- (if (failed-ns not-found-ns)
- (throw e)
- (if (compile-ns not-found-ns (conj failed-ns ns))
- (do
- (println "Failure resolved.")
- (compile-ns ns failed-ns))
- (throw e))))
- (throw e))))))))
+ cnfe-pattern #".*java\.lang\.ClassNotFoundException: ([a-zA-z0-9-_.]+)(, compiling:| )\(.*:\d+\)$"]
+ (if-let [matches (re-matches cnfe-pattern msg)]
+ (let [not-found-ns (symbol (matches 1))]
+ (println (format "Dependency failure detected, will try to compile %s." not-found-ns))
+ (if (failed-ns not-found-ns)
+ (throw e)
+ (if (compile-ns not-found-ns (conj failed-ns ns))
+ (do
+ (println "Failure resolved.")
+ (compile-ns ns failed-ns))
+ (throw e))))
+ (throw e)))))))
([ns]
(compile-ns ns #{})))
6 src/clojure/neko/_protocols/resolvable.clj
View
@@ -55,6 +55,12 @@
(resolve-string [id _] id)
(resolve-layout [id _] id)
+ Long
+ (resolve-it [id _1 _2] (.intValue id))
+ (resolve-id [id _] (.intValue id))
+ (resolve-string [id _] (.intValue id))
+ (resolve-layout [id _] (.intValue id))
+
clojure.lang.Keyword
(resolve-it
[name context type] (resolve-from-keyword context type name))
6 src/clojure/neko/find_view.clj
View
@@ -84,6 +84,12 @@
:post [(nil-or-view? %)]}
(find-view *activity* id))
+ Long
+ (find-view [id]
+ {:pre [(has-*activity*?)]
+ :post [(nil-or-view? %)]}
+ (find-view *activity* (.intValue id)))
+
clojure.lang.Keyword
(find-view [id]
{:pre [(has-*activity*?)]
21 test-app/AndroidManifest.xml
View
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.sattvik.neko.test_app"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="7"
- android:targetSdkVersion="10"/>
- <application android:label="@string/app_name" android:icon="@drawable/icon">
- <activity android:name="TestActivity"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.READ_LOGS"/>
-</manifest>
-
-<!-- vim:set ts=4 sw=4 et: -->
19 test-app/ant.properties
View
@@ -1,19 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
-android.library.reference.1=..
-clojure.warn.reflection=true
85 test-app/build.xml
View
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="NekoTestApp" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
-
- <!-- The ant.properties file can be created by you. It is only edited by the
- 'android' tool to add properties to it.
- This is the place to change some Ant specific build properties.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- For other overridable properties, look at the beginning of the rules
- files in the SDK, at tools/ant/build.xml
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="ant.properties" />
-
- <!-- The project.properties file is created and updated by the 'android'
- tool, as well as ADT.
-
- This contains project specific properties such as project target, and library
- dependencies. Lower level build properties are stored in ant.properties
- (or in .classpath for Eclipse projects).
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <loadproperties srcFile="project.properties" />
-
- <!-- quick check on sdk.dir -->
- <fail
- message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
- unless="sdk.dir"
- />
-
- <!--
- Import per project custom build rules if present at the root of the project.
- This is the place to put custom intermediary targets such as:
- -pre-build
- -pre-compile
- -post-compile (This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir})
- -post-package
- -post-build
- -pre-clean
- -->
- <import file="custom_rules.xml" optional="true" />
-
- <import file="../build-support/clojure.xml" />
-
- <!-- Import the actual build file.
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <import> task.
- - customize it to your needs.
- - Customize the whole content of build.xml
- - copy/paste the content of the rules files (minus the top node)
- into this file, replacing the <import> task.
- - customize to your needs.
-
- ***********************
- ****** IMPORTANT ******
- ***********************
- In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
- in order to avoid having your file be overridden by tools such as "android update project"
- -->
- <!-- version-tag: custom -->
- <import file="${sdk.dir}/tools/ant/build.xml" />
-
-</project>
20 test-app/proguard-project.txt
View
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
40 test-app/proguard.cfg
View
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
11 test-app/project.properties
View
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-7
14 test/AndroidManifest.xml
View
@@ -9,7 +9,14 @@
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
- <application>
+ <application android:label="@string/app_name" android:icon="@drawable/icon">
+ <activity android:name="TestActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
<uses-library android:name="android.test.runner" />
</application>
<!--
@@ -18,8 +25,11 @@
"adb shell am instrument -w clojure.contrib.android.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.sattvik.neko.test_app"
+ android:targetPackage="com.sattvik.neko.tests"
android:label="Tests for Neko"/>
+
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.READ_LOGS"/>
</manifest>
<!-- vim:set et sw=4 ts=4: -->
1  test/ant.properties
View
@@ -16,4 +16,3 @@
# The password will be asked during the build when you use the 'release' target.
android.library.reference.1=..
-tested.project.dir=../test-app
57 test/build.xml
View
@@ -61,6 +61,63 @@
<import file="../build-support/clojure.xml" />
+ <target name="test"
+ description="Runs tests from the package defined in test.package property">
+
+ <property name="tested.project.absolute.dir" location="." />
+
+ <property name="test.runner" value="android.test.InstrumentationTestRunner" />
+
+ <!-- Application package of the tested project extracted from its manifest file -->
+ <xpath input="${tested.project.absolute.dir}/AndroidManifest.xml"
+ expression="/manifest/@package" output="tested.manifest.package" />
+ <xpath input="AndroidManifest.xml"
+ expression="/manifest/@package" output="manifest.package" />
+
+ <property name="emma.dump.file"
+ value="/data/data/${tested.manifest.package}/coverage.ec" />
+
+ <if condition="${emma.enabled}">
+ <then>
+ <echo>WARNING: Code Coverage is currently only supported on the emulator and rooted devices.</echo>
+ <run-tests-helper emma.enabled="true">
+ <extra-instrument-args>
+ <arg value="-e" />
+ <arg value="coverageFile" />
+ <arg value="${emma.dump.file}" />
+ </extra-instrument-args>
+ </run-tests-helper>
+ <echo>Downloading coverage file into project directory...</echo>
+ <exec executable="${adb}" failonerror="true">
+ <arg line="${adb.device.arg}" />
+ <arg value="pull" />
+ <arg value="${emma.dump.file}" />
+ <arg value="coverage.ec" />
+ </exec>
+ <echo>Extracting coverage report...</echo>
+ <emma>
+ <report sourcepath="${tested.project.absolute.dir}/${source.dir}"
+ verbosity="${verbosity}">
+ <!-- TODO: report.dir or something like should be introduced if necessary -->
+ <infileset dir=".">
+ <include name="coverage.ec" />
+ <include name="coverage.em" />
+ </infileset>
+ <!-- TODO: reports in other, indicated by user formats -->
+ <html outfile="coverage.html" />
+ </report>
+ </emma>
+ <echo>Cleaning up temporary files...</echo>
+ <delete file="coverage.ec" />
+ <delete file="coverage.em" />
+ <echo>Saving the report file in ${basedir}/coverage/coverage.html</echo>
+ </then>
+ <else>
+ <run-tests-helper />
+ </else>
+ </if>
+ </target>
+
<!-- Import the actual build file.
To customize existing targets, there are two options:
0  test-app/res/drawable-hdpi/icon.png → test/res/drawable-hdpi/icon.png
View
File renamed without changes
0  test-app/res/drawable-ldpi/icon.png → test/res/drawable-ldpi/icon.png
View
File renamed without changes
0  test-app/res/drawable-mdpi/icon.png → test/res/drawable-mdpi/icon.png
View
File renamed without changes
0  test-app/res/layout/main.xml → test/res/layout/main.xml
View
File renamed without changes
0  test-app/res/values/strings.xml → test/res/values/strings.xml
View
File renamed without changes
4 ...lojure/com/sattvik/neko/test_app/TestActivity.clj → ...c/clojure/com/sattvik/neko/tests/TestActivity.clj
View
@@ -9,11 +9,11 @@
; terms of this license. You must not remove this notice, or any other, from
; this software.
-(ns com.sattvik.neko.test_app.TestActivity
+(ns com.sattvik.neko.tests.TestActivity
(:gen-class :main false
:extends android.app.Activity
:exposes-methods {onCreate superOnCreate})
- (:import com.sattvik.neko.test_app.R$layout))
+ (:import com.sattvik.neko.tests.R$layout))
(def set-content-view? (atom true))
6 test/src/clojure/neko/activity_test.clj
View
@@ -29,8 +29,8 @@
[testRequestWindowFeaturesManyFeaturesInContext [] void]
[testRequestWindowFeaturesBadFeatures [] void]])
(:import android.view.Window
- com.sattvik.neko.test_app.R$id)
- (:require [com.sattvik.neko.test_app.TestActivity :as test-activity])
+ com.sattvik.neko.tests.R$id)
+ (:require [com.sattvik.neko.tests.TestActivity :as test-activity])
(:use [neko activity
[context :only [*context*]]
find-view
@@ -38,7 +38,7 @@
junit.assert))
(defn -init []
- [[com.sattvik.neko.test_app.TestActivity] nil])
+ [[com.sattvik.neko.tests.TestActivity] nil])
(defn -testWithActivity
"Test that the with-activity macro."
10 test/src/clojure/neko/context_test.clj
View
@@ -23,7 +23,7 @@
[testInflateLayout [] void]]
:exposes-methods {setUp superSetUp})
(:import android.content.Context
- [com.sattvik.neko.test_app R$id R$layout R$string])
+ [com.sattvik.neko.tests R$id R$layout R$string])
(:use neko.context
junit.assert))
@@ -45,9 +45,9 @@
(defn -testResolveResource
"Tests the resolve-resource function."
[this]
- (let [test-string-id com.sattvik.neko.test_app.R$string/test_string
- icon-id com.sattvik.neko.test_app.R$drawable/icon
- layout-id com.sattvik.neko.test_app.R$layout/main]
+ (let [test-string-id com.sattvik.neko.tests.R$string/test_string
+ icon-id com.sattvik.neko.tests.R$drawable/icon
+ layout-id com.sattvik.neko.tests.R$layout/main]
; basic tests
(is-eq test-string-id
(resolve-resource @context :string :test_string))
@@ -64,7 +64,7 @@
; test using namespace
(is-eq test-string-id
(resolve-resource @context :string
- :com.sattvik.neko.test_app/test-string))
+ :com.sattvik.neko.tests/test-string))
; basic tests with context
(with-context @context
(is-eq test-string-id
2  test/src/clojure/neko/dialog/alert_test.clj
View
@@ -47,7 +47,7 @@
(defn start-activity []
(when-not @activity
(let [package (.. @the-test getInstrumentation getTargetContext getPackageName) ]
- (reset! activity (.launchActivity @the-test package com.sattvik.neko.test_app.TestActivity nil))))
+ (reset! activity (.launchActivity @the-test package com.sattvik.neko.tests.TestActivity nil))))
@activity)
(defn -setUp
4 test/src/clojure/neko/find_view_test.clj
View
@@ -21,14 +21,14 @@
[testView [] void]
[testDialog [] void]
[testOneArg [] void]])
- (:import [com.sattvik.neko.test_app R$id R$layout])
+ (:import [com.sattvik.neko.tests R$id R$layout])
(:use [neko activity
find-view
test-utils]
junit.assert))
(defn -init []
- [[com.sattvik.neko.test_app.TestActivity] nil])
+ [[com.sattvik.neko.tests.TestActivity] nil])
(defn -testActivity
"Tests the ViewFinder protocol with an Activity."
4 test/src/clojure/neko/test_utils.clj
View
@@ -20,8 +20,8 @@
(doto (Intent.)
(.addCategory Intent/CATEGORY_LAUNCHER)
(.addFlags Intent/FLAG_ACTIVITY_NEW_TASK)
- (.setClassName "com.sattvik.neko.test_app"
- "com.sattvik.neko.test_app.TestActivity")
+ (.setClassName "com.sattvik.neko.tests"
+ "com.sattvik.neko.tests.TestActivity")
(.setAction Intent/ACTION_MAIN)))
(defn start-activity
2  test/src/clojure/neko/threading_test.clj
View
@@ -33,7 +33,7 @@
junit.assert))
(defn -init []
- [[com.sattvik.neko.test_app.TestActivity] nil])
+ [[com.sattvik.neko.tests.TestActivity] nil])
(defn -testRunOnUiThread [this]
(let [ui-thread (Thread/currentThread)
Please sign in to comment.
Something went wrong with that request. Please try again.