Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.

Commit 37e439c

Browse files
author
Lyla
committed
4.08 Adding weather with location to the uribuilder
1 parent 44facd1 commit 37e439c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.example.android.sunshine.app.data;
1717

18+
import android.net.Uri;
1819
import android.test.AndroidTestCase;
1920

2021
/*
@@ -30,15 +31,15 @@ public class TestWeatherContract extends AndroidTestCase {
3031
/*
3132
Students: Uncomment this out to test your weather location function.
3233
*/
33-
// public void testBuildWeatherLocation() {
34-
// Uri locationUri = WeatherContract.WeatherEntry.buildWeatherLocation(TEST_WEATHER_LOCATION);
35-
// assertNotNull("Error: Null Uri returned. You must fill-in buildWeatherLocation in " +
36-
// "WeatherContract.",
37-
// locationUri);
38-
// assertEquals("Error: Weather location not properly appended to the end of the Uri",
39-
// TEST_WEATHER_LOCATION, locationUri.getLastPathSegment());
40-
// assertEquals("Error: Weather location Uri doesn't match our expected result",
41-
// locationUri.toString(),
42-
// "content://com.example.android.sunshine.app/weather/%2FNorth%20Pole");
43-
// }
34+
public void testBuildWeatherLocation() {
35+
Uri locationUri = WeatherContract.WeatherEntry.buildWeatherLocation(TEST_WEATHER_LOCATION);
36+
assertNotNull("Error: Null Uri returned. You must fill-in buildWeatherLocation in " +
37+
"WeatherContract.",
38+
locationUri);
39+
assertEquals("Error: Weather location not properly appended to the end of the Uri",
40+
TEST_WEATHER_LOCATION, locationUri.getLastPathSegment());
41+
assertEquals("Error: Weather location Uri doesn't match our expected result",
42+
locationUri.toString(),
43+
"content://com.example.android.sunshine.app/weather/%2FNorth%20Pole");
44+
}
4445
}

app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ public static Uri buildWeatherUri(long id) {
131131
}
132132

133133
/*
134-
Student: Fill in this buildWeatherLocation function
134+
Student: This is the buildWeatherLocation function you filled in.
135135
*/
136136
public static Uri buildWeatherLocation(String locationSetting) {
137-
return null;
137+
return CONTENT_URI.buildUpon().appendPath(locationSetting).build();
138138
}
139139

140140
public static Uri buildWeatherLocationWithStartDate(

0 commit comments

Comments
 (0)