Skip to content

Commit ab45cd6

Browse files
committed
Temperature - Adds the tests
1 parent 2918657 commit ab45cd6

6 files changed

Lines changed: 39 additions & 9 deletions

File tree

com.vogella.android.temperatureconverter/app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 22
5-
buildToolsVersion "23.0.0 rc2"
5+
buildToolsVersion '23.0.0 rc2'
66

77
defaultConfig {
88
applicationId "com.vogella.android.temperatureconverter"
@@ -20,5 +20,6 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
}
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
24+
testCompile 'junit:junit:4.12'
25+
}

com.vogella.android.temperatureconverter/app/src/main/java/com/vogella/android/temperatureconverter/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class MainActivity extends Activity {
1414
public void onCreate(Bundle savedInstanceState) {
1515
super.onCreate(savedInstanceState);
1616
setContentView(R.layout.activity_main);
17-
text = (EditText) findViewById(R.id.editText1);
17+
text = (EditText) findViewById(R.id.inputValue);
1818

1919
}
2020

com.vogella.android.temperatureconverter/app/src/main/res/layout/activity_main.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<EditText
1515
android:layout_width="match_parent"
1616
android:layout_height="wrap_content"
17-
android:id="@+id/editText1" />
17+
android:id="@+id/inputValue"
18+
android:inputType="numberSigned|numberDecimal"/>
1819

1920
<RadioGroup
2021
android:id="@+id/radioGroup1"
@@ -28,13 +29,13 @@
2829
android:layout_width="wrap_content"
2930
android:layout_height="wrap_content"
3031
android:checked="true"
31-
android:text="RadioButton" />
32+
android:text="@string/celsius" />
3233

3334
<RadioButton
3435
android:id="@+id/radio1"
3536
android:layout_width="wrap_content"
3637
android:layout_height="wrap_content"
37-
android:text="RadioButton" />
38+
android:text="@string/fahrenheit" />
3839
</RadioGroup>
3940

4041
<Button
@@ -44,6 +45,7 @@
4445
android:layout_alignStart="@+id/radioGroup1"
4546
android:layout_below="@+id/radioGroup1"
4647
android:layout_marginTop="22dp"
47-
android:text="Button" />
48+
android:text="@string/calc"
49+
android:onClick="onClick"/>
4850

4951
</LinearLayout>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.vogella.android.temperatureconverter;
2+
3+
import org.junit.runner.RunWith;
4+
import org.junit.runners.Suite;
5+
import org.junit.runners.Suite.SuiteClasses;
6+
7+
@RunWith(Suite.class)
8+
@SuiteClasses({
9+
ConverterTest.class
10+
})
11+
12+
public class AllTests {
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.vogella.android.temperatureconverter;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class ConverterTest {
7+
@Test
8+
public void testConvert() {
9+
float actual = ConverterUtil.convertCelsiusToFahrenheit(100);
10+
float expected = 212;
11+
assertEquals("Conversion from celsius to fahrenheit failed", expected,
12+
actual, 0.001);
13+
}
14+
}

com.vogella.android.temperatureconverter/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.2.3'
8+
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

0 commit comments

Comments
 (0)