diff options
| author | Brian Attwell <brianattwell@google.com> | 2014-02-04 21:14:02 -0800 |
|---|---|---|
| committer | Brian Attwell <brianattwell@google.com> | 2014-02-04 21:14:02 -0800 |
| commit | fc50bdd15a2de6560581b67d3b73688a48ae0b3f (patch) | |
| tree | 52224f65e91a90af480200f38710a70c3ad6158d /tests | |
| parent | b5c7e0402458fc26c59ec9f7087183d7739c67ee (diff) | |
| download | packages_apps_Contacts-fc50bdd15a2de6560581b67d3b73688a48ae0b3f.tar.gz packages_apps_Contacts-fc50bdd15a2de6560581b67d3b73688a48ae0b3f.tar.bz2 packages_apps_Contacts-fc50bdd15a2de6560581b67d3b73688a48ae0b3f.zip | |
Delete dead social/stream code from Contacts
Searched for stream/social code. Next, deleted layouts that
showed up in the results from "lint Contacts --check UnusedResources".
I didn't bother cleaning up the unused strings.
Change-Id: I7473127e8e4e33c97b205f85d4d63f459e9d2b10
Diffstat (limited to 'tests')
7 files changed, 0 insertions, 663 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 7a7df01e8..46e7ac3e3 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -76,16 +76,6 @@ </intent-filter> </activity> - <activity android:name=".streamitems.StreamItemPopulatorActivity" - android:label="@string/streamItemPopulator" - > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.DEFAULT" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <!-- Test authenticators/sync adapters. diff --git a/tests/res/layout/stream_item_populator.xml b/tests/res/layout/stream_item_populator.xml deleted file mode 100644 index acc46bf46..000000000 --- a/tests/res/layout/stream_item_populator.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" -> - <Button - android:id="@+id/add" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/chooseAContactButton" - android:layout_marginBottom="50px" - /> - <Button - android:id="@+id/exit" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/exitButton" - /> -</LinearLayout> diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml index b3f3ee7da..44283ff5e 100644 --- a/tests/res/values/donottranslate_strings.xml +++ b/tests/res/values/donottranslate_strings.xml @@ -97,10 +97,7 @@ <string name="useRandomNumbers">Use random numbers</string> <string name="addedLogEntriesToast">Added %1$d call log entries.</string> <string name="noLogEntriesToast">No entries in the call log yet. Need at least one record for the template. Or use random numbers.</string> - - <string name="chooseAContactButton">Choose a contact to add stream items to</string> <string name="exitButton">Exit</string> - <string name="streamItemPopulator">Populate stream items</string> <string-array name="pinnedHeaderUseCases"> <item>One short section - no headers</item> diff --git a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java b/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java deleted file mode 100644 index 07b3691d0..000000000 --- a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.contacts.detail; - -import android.content.Context; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.text.Html; -import android.text.Spanned; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - -import com.android.contacts.R; -import com.android.contacts.util.StreamItemEntry; -import com.android.contacts.util.StreamItemEntryBuilder; - -/** - * Unit tests for {@link ContactDetailDisplayUtils}. - */ -@SmallTest -public class ContactDetailDisplayUtilsTest extends AndroidTestCase { - private static final String TEST_STREAM_ITEM_TEXT = "text"; - - private LayoutInflater mLayoutInflater; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mLayoutInflater = - (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testAddStreamItemText_IncludesComments() { - StreamItemEntry streamItem = getTestBuilder().setComment("1 comment").build(getContext()); - View streamItemView = addStreamItemText(streamItem); - assertHasText(streamItemView, R.id.stream_item_comments, "1 comment"); - } - - public void testAddStreamItemText_IncludesHtmlComments() { - StreamItemEntry streamItem = getTestBuilder().setComment("1 <b>comment</b>") - .build(getContext()); - View streamItemView = addStreamItemText(streamItem); - assertHasHtmlText(streamItemView, R.id.stream_item_comments, "1 <b>comment<b>"); - } - - public void testAddStreamItemText_NoComments() { - StreamItemEntry streamItem = getTestBuilder().setComment(null).build(getContext()); - View streamItemView = addStreamItemText(streamItem); - assertGone(streamItemView, R.id.stream_item_comments); - } - - /** Checks that the given id corresponds to a visible text view with the expected text. */ - private void assertHasText(View parent, int textViewId, String expectedText) { - TextView textView = (TextView) parent.findViewById(textViewId); - assertNotNull(textView); - assertEquals(View.VISIBLE, textView.getVisibility()); - assertEquals(expectedText, textView.getText().toString()); - } - - /** Checks that the given id corresponds to a visible text view with the expected HTML. */ - private void assertHasHtmlText(View parent, int textViewId, String expectedHtml) { - TextView textView = (TextView) parent.findViewById(textViewId); - assertNotNull(textView); - assertEquals(View.VISIBLE, textView.getVisibility()); - assertSpannableEquals(Html.fromHtml(expectedHtml), textView.getText()); - } - - /** - * Asserts that a char sequence is actually a {@link Spanned} matching the one expected. - */ - private void assertSpannableEquals(Spanned expected, CharSequence actualCharSequence) { - assertEquals(expected.toString(), actualCharSequence.toString()); - assertTrue("char sequence should be an instance of Spanned", - actualCharSequence instanceof Spanned); - Spanned actual = (Spanned) actualCharSequence; - assertEquals(Html.toHtml(expected), Html.toHtml(actual)); - } - - /** Checks that the given id corresponds to a gone view. */ - private void assertGone(View parent, int textId) { - View view = parent.findViewById(textId); - assertNotNull(view); - assertEquals(View.GONE, view.getVisibility()); - } - - /** - * Calls {@link ContactDetailDisplayUtils#addStreamItemText(LayoutInflater, Context, - * StreamItemEntry, View)} with the default parameters and the given stream item. - */ - private View addStreamItemText(StreamItemEntry streamItem) { - return ContactDetailDisplayUtils.addStreamItemText(getContext(), streamItem, - mLayoutInflater.inflate(R.layout.stream_item_container, null)); - } - - private StreamItemEntryBuilder getTestBuilder() { - return new StreamItemEntryBuilder().setText(TEST_STREAM_ITEM_TEXT); - } -} diff --git a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java b/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java deleted file mode 100644 index 9132e4002..000000000 --- a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.contacts.tests.streamitems; - -import android.app.Activity; -import android.content.ContentProviderOperation; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.provider.ContactsContract; -import android.provider.ContactsContract.RawContacts; -import android.provider.ContactsContract.StreamItemPhotos; -import android.provider.ContactsContract.StreamItems; -import android.view.View; -import android.widget.Button; -import android.widget.Toast; - -import com.android.contacts.common.model.account.GoogleAccountType; -import com.android.contacts.tests.R; -import com.google.common.collect.Lists; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Random; - -/** - * Testing activity that will populate stream items and stream item photos to selected - * entries in the user's contacts list. - * - * The contact selected must have at least one raw contact that was provided by Google. - */ -public class StreamItemPopulatorActivity extends Activity { - - // Test data to randomly select from. - private String[] snippetStrings = new String[]{ - "Just got back from a vacation in %1$s - what a great place! Can't wait to go back.", - "If I never see %1$s again it will be too soon.", - "This is a public service announcement. If you were even close to considering visiting" - + " %1$s, I strongly advise you to reconsider. The food was terrible, the people were " - + "rude, the hygiene of the bus and taxi drivers was positively <i>barbaric</i>. I " - + "feared for my life almost the entire time I was there, and feel lucky to be back " - + "<b>home</b>.", - "Check out these pictures! I took them in %1$s" - }; - - private String[] placeNames = new String[]{ - "the Google campus in Mountain View", - "the deserts on Arrakis", - "Iceland", - "Japan", - "Sydney", - "San Francisco", - "Munich", - "Istanbul", - "Tanagra", - "the restricted section of Area 51", - "the middle of nowhere" - }; - - private String[] commentStrings = new String[]{ - "3 retweets", - "5 shares", - "4 likes", - "4 +1s", - "<i>24567</i> <font color='blue' size='+1'><b>likes</b></font>" - }; - - private String[] labelResources = new String[] { - "attribution_google_plus", - "attribution_google_talk", - "attribution_flicker", - "attribution_twitter" - }; - - public String[] iconResources = new String[] { - "default_icon" - }; - - // Photos to randomly select from. - private Integer[] imageIds = new Integer[]{ - R.drawable.android, - R.drawable.goldengate, - R.drawable.iceland, - R.drawable.japan, - R.drawable.sydney, - R.drawable.wharf, - R.drawable.whiskey - }; - - // Only some photos have actions. - private String[] imageStrings = new String[]{ - "android", - "goldengate", - "iceland", - "japan", - }; - - // The contact ID that was picked. - private long mContactId = -1; - - private Random mRandom; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mRandom = new Random(System.currentTimeMillis()); - - setContentView(R.layout.stream_item_populator); - Button pickButton = (Button) findViewById(R.id.add); - pickButton.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v) { - // Reset the contact ID. - mContactId = -1; - - // Forward the Intent to the picker - final Intent pickerIntent = - new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); - pickerIntent.setFlags( - Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivityForResult(pickerIntent, 0); - } - }); - - Button exitButton = (Button) findViewById(R.id.exit); - exitButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (resultCode == Activity.RESULT_OK) { - Uri contactUri = data.getData(); - mContactId = ContentUris.parseId(contactUri); - } - } - - @Override - protected void onResume() { - super.onResume(); - if (mContactId != -1) { - long rawContactId = -1; - String accountType = null; - String accountName = null; - String dataSet = null; - - // Lookup the com.google raw contact for the contact. - Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, - new String[]{ - RawContacts._ID, - RawContacts.ACCOUNT_TYPE, - RawContacts.ACCOUNT_NAME - }, - RawContacts.CONTACT_ID + "=? AND " + RawContacts.ACCOUNT_TYPE + "=?", - new String[]{String.valueOf(mContactId), GoogleAccountType.ACCOUNT_TYPE}, null); - try { - c.moveToFirst(); - rawContactId = c.getLong(0); - accountType = c.getString(1); - accountName = c.getString(2); - } finally { - c.close(); - } - if (rawContactId != -1) { - addStreamItemsToRawContact(rawContactId, accountType, accountName); - } else { - Toast.makeText(this, - "Failed to find raw contact ID for contact ID " + mContactId, 5).show(); - } - } - } - - protected byte[] loadPhotoFromResource(int resourceId) { - InputStream is = getResources().openRawResource(resourceId); - return readInputStreamFully(is); - } - - protected byte[] readInputStreamFully(InputStream is) { - try { - byte[] buffer = new byte[is.available()]; - is.read(buffer); - is.close(); - return buffer; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private void addStreamItemsToRawContact(long rawContactId, String accountType, - String accountName) { - ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); - - // Add from 1-5 stream items. - int itemsToAdd = randInt(5) + 1; - int opCount = 0; - for (int i = 0; i < itemsToAdd; i++) { - ContentValues streamItemValues = buildStreamItemValues(accountType, accountName); - ops.add(ContentProviderOperation.newInsert( - Uri.withAppendedPath( - ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, - rawContactId), - ContactsContract.RawContacts.StreamItems.CONTENT_DIRECTORY)) - .withValues(streamItemValues).build()); - - // Maybe add photos - 30% chance per stream item. - boolean includePhotos = randInt(100) < 30; - if (includePhotos) { - // Add 1-5 photos if we're including any. - int numPhotos = randInt(5) + 1; - for (int j = 0; j < numPhotos; j++) { - ContentValues streamItemPhotoValues = - buildStreamItemPhotoValues(j, accountType, accountName); - ops.add(ContentProviderOperation.newInsert(StreamItems.CONTENT_PHOTO_URI) - .withValues(streamItemPhotoValues) - .withValueBackReference(StreamItemPhotos.STREAM_ITEM_ID, opCount) - .build()); - } - opCount += numPhotos; - } - opCount++; - } - try { - getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); - } catch (Exception e) { - // We don't care. This is just for test purposes. - throw new RuntimeException(e); - } - Toast.makeText(this, "Added " + itemsToAdd + " stream item(s) and " - + (opCount - itemsToAdd) + " photos", 5).show(); - } - - private ContentValues buildStreamItemValues(String accountType, String accountName) { - boolean includeAttribution = randInt(100) < 70; - boolean includeComments = randInt(100) < 30; - boolean includeAction = randInt(100) < 30; - ContentValues values = new ContentValues(); - String place = pickRandom(placeNames); - values.put(StreamItems.TEXT, - String.format(pickRandom(snippetStrings) , place) - + (includeComments ? " [c]" : "") - + (includeAction ? " [a]" : "")); - if (includeAttribution) { - values.put(StreamItems.RES_PACKAGE, "com.android.contacts.tests"); - int sourceIndex = randInt(labelResources.length); - values.put(StreamItems.RES_LABEL, labelResources[sourceIndex]); - if (sourceIndex < iconResources.length) { - values.put(StreamItems.RES_ICON, iconResources[sourceIndex]); - } - } - if (includeComments) { - values.put(StreamItems.COMMENTS, pickRandom(commentStrings)); - } else { - values.put(StreamItems.COMMENTS, ""); - } - // Set the timestamp to some point in the past. - values.put(StreamItems.TIMESTAMP, - System.currentTimeMillis() - randInt(360000000)); - values.put(RawContacts.ACCOUNT_TYPE, accountType); - values.put(RawContacts.ACCOUNT_NAME, accountName); - return values; - } - - private ContentValues buildStreamItemPhotoValues(int index, String accountType, - String accountName) { - Integer imageIndex = pickRandom(imageIds); - ContentValues values = new ContentValues(); - values.put(StreamItemPhotos.SORT_INDEX, index); - values.put(StreamItemPhotos.PHOTO, loadPhotoFromResource(imageIndex)); - values.put(RawContacts.ACCOUNT_TYPE, accountType); - values.put(RawContacts.ACCOUNT_NAME, accountName); - return values; - } - - private <T> T pickRandom(T[] from) { - return from[randInt(from.length)]; - } - - private int randInt(int max) { - return Math.abs(mRandom.nextInt()) % max; - } -} diff --git a/tests/src/com/android/contacts/util/HtmlUtilsTest.java b/tests/src/com/android/contacts/util/HtmlUtilsTest.java deleted file mode 100644 index 772e78f18..000000000 --- a/tests/src/com/android/contacts/util/HtmlUtilsTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.contacts.util; - -import android.graphics.drawable.ColorDrawable; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.text.SpannableStringBuilder; -import android.text.Spanned; -import android.text.SpannedString; -import android.text.style.ImageSpan; -import android.text.style.QuoteSpan; - -import com.android.contacts.util.HtmlUtils.StreamItemQuoteSpan; - -/** - * Tests for {@link HtmlUtils}. - * - * adb shell am instrument -w -e class com.android.contacts.util.HtmlUtilsTest \ - com.android.contacts.tests/android.test.InstrumentationTestRunner - */ -@SmallTest -public class HtmlUtilsTest extends AndroidTestCase { - /** - * Test for {@link HtmlUtils#postprocess} specifically about trimming newlines. - */ - public void testPostProcess_trimNewLines() { - checkTrimNewLines("", ""); - checkTrimNewLines("", "\n"); - checkTrimNewLines("", "\n\n"); - checkTrimNewLines("a", "a"); - checkTrimNewLines("abc", "abc"); - checkTrimNewLines("abc", "abc\n"); - checkTrimNewLines("abc", "abc\n\n\n"); - checkTrimNewLines("ab\nc", "ab\nc\n"); - - assertNull(HtmlUtils.postprocess(getContext(), null)); - } - - private final void checkTrimNewLines(String expectedString, CharSequence text) { - // Test with both SpannedString and SpannableStringBuilder. - assertEquals(expectedString, - HtmlUtils.postprocess(getContext(), new SpannedString(text)).toString()); - - assertEquals(expectedString, - HtmlUtils.postprocess(getContext(), new SpannableStringBuilder(text)).toString()); - } - - public void testPostProcess_with_newlines() { - final SpannableStringBuilder builder = new SpannableStringBuilder("01234\n\n"); - - setSpans(builder); - - // First test with a SpannableStringBuilder, as opposed to SpannedString - checkPostProcess(HtmlUtils.postprocess(getContext(), builder)); - - // Then pass a SpannedString, which is immutable, but the method should still work. - checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder))); - } - - /** - * Same as {@link #testPostProcess_with_newlines}, but text has no newlines. - * (The internal code path is slightly different.) - */ - public void testPostProcess_no_newlines() { - final SpannableStringBuilder builder = new SpannableStringBuilder("01234"); - - setSpans(builder); - - // First test with a SpannableStringBuilder, as opposed to SpannedString - checkPostProcess(HtmlUtils.postprocess(getContext(), builder)); - - // Then pass a SpannedString, which is immutable, but the method should still work. - checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder))); - } - - private void setSpans(SpannableStringBuilder builder) { - builder.setSpan(new ImageSpan(new ColorDrawable(), ImageSpan.ALIGN_BOTTOM), 0, 2, 0); - builder.setSpan(new QuoteSpan(), 2, 4, 0); - builder.setSpan(new CustomSpan(), 4, builder.length(), 0); - } - - private void checkPostProcess(Spanned ret) { - // Newlines should be trimmed. - assertEquals("01234", ret.toString()); - - // First, check the image span. - // - Vertical alignment should be changed to ALIGN_BASELINE - // - Drawable shouldn't be changed. - ImageSpan[] imageSpans = ret.getSpans(0, ret.length(), ImageSpan.class); - assertEquals(1, imageSpans.length); - assertEquals(ImageSpan.ALIGN_BASELINE, imageSpans[0].getVerticalAlignment()); - assertEquals(ColorDrawable.class, imageSpans[0].getDrawable().getClass()); - - // QuoteSpans should be replaced with StreamItemQuoteSpans. - QuoteSpan[] quoteSpans = ret.getSpans(0, ret.length(), QuoteSpan.class); - assertEquals(1, quoteSpans.length); - assertEquals(StreamItemQuoteSpan.class, quoteSpans[0].getClass()); - - // Other spans should be preserved. - CustomSpan[] customSpans = ret.getSpans(0, ret.length(), CustomSpan.class); - assertEquals(1, customSpans.length); - } - - /** Custom span class used in {@link #testPostProcess} */ - private static class CustomSpan { - } -} diff --git a/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java b/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java deleted file mode 100644 index 9eb550e40..000000000 --- a/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.contacts.util; - -import android.content.Context; - -/** - * Builder for {@link StreamItemEntry}s to make writing tests easier. - */ -public class StreamItemEntryBuilder { - private long mId; - private String mText; - private String mComment; - private long mTimestamp; - private String mAccountType; - private String mAccountName; - private String mDataSet; - private String mResPackage; - private String mIconRes; - private String mLabelRes; - - public StreamItemEntryBuilder() {} - - public StreamItemEntryBuilder setText(String value) { - mText = value; - return this; - } - - public StreamItemEntryBuilder setComment(String value) { - mComment = value; - return this; - } - - public StreamItemEntryBuilder setAccountType(String value) { - mAccountType = value; - return this; - } - - public StreamItemEntryBuilder setAccountName(String value) { - mAccountName = value; - return this; - } - - public StreamItemEntryBuilder setDataSet(String value) { - mDataSet = value; - return this; - } - - public StreamItemEntry build(Context context) { - StreamItemEntry ret = StreamItemEntry.createForTest(mId, mText, mComment, mTimestamp, - mAccountType, mAccountName, mDataSet, mResPackage, mIconRes, mLabelRes); - ret.decodeHtml(context); - return ret; - } -} |
