-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basics for ContentProvider testing. #7
Changes from all commits
f522975
3e10ff5
9e98460
019db5d
db021e4
91317be
f820b8f
94489bd
a45b1a6
342e7da
31d1e1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.g11x.checklistapp; | ||
|
||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.ProviderTestCase2; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Tests for the app's ContentProvider. | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class LocalRepositoryTest extends ProviderTestCase2<LocalRepository> { | ||
public LocalRepositoryTest() { | ||
super(LocalRepository.class, InstrumentationRegistry.getInstrumentation().getTargetContext().getString(R.string.content_provider_authority)); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
setContext(InstrumentationRegistry.getTargetContext()); | ||
super.setUp(); | ||
} | ||
|
||
@Test | ||
public void shouldFetchData() { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.g11x.checklistapp; | ||
|
||
/** | ||
* Created by wcalabrese on 8/15/16. | ||
*/ | ||
|
||
public class Constants { | ||
public static final String LOCAL_REPOSITORY_AUTHORITY = "com.g11x.checklistapp.provider"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can declare this in build.gradle as a res property and then use it in the manifest as well as within the app getString(context, R.string.thing). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In build.gradle add resValue("string", "content_provider_authority", "packagename") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 mind blown 🔥
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, android.defaultConfig element. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. PTAL. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.g11x.checklistapp; | ||
|
||
import android.content.ContentProvider; | ||
import android.content.ContentValues; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.support.annotation.Nullable; | ||
|
||
/** Application data repository. */ | ||
public class LocalRepository extends ContentProvider { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had a question that got buried in a previous commit. Just so it doesn't get lost in the shuffle: #7 (diff) |
||
@Override | ||
public boolean onCreate() { | ||
return false; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) { | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getType(Uri uri) { | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Uri insert(Uri uri, ContentValues contentValues) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int delete(Uri uri, String s, String[] strings) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) { | ||
return 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are like tables in a database, right? If so, how about something specific to the items in the table, like
.ChecklistItems
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Authorities are like databases, not tables within the db. It would be rather rare for a single app to have more than one.