1 package com.android.calendar;
3 import android.database.Cursor;
4 import android.database.MatrixCursor;
5 import android.test.suitebuilder.annotation.SmallTest;
7 import junit.framework.TestCase;
9 import java.util.HashMap;
13 * Test class for verifying helper functions in Calendar's Utils
15 * You can run these tests with the following command:
16 * "adb shell am instrument -w -e class com.android.calendar.UtilsTests
17 * com.android.calendar.tests/android.test.InstrumentationTestRunner"
19 public class UtilsTests extends TestCase {
20 HashMap<String, Boolean> mIsDuplicateName;
21 HashMap<String, Boolean> mIsDuplicateNameExpected;
22 MatrixCursor mDuplicateNameCursor;
24 private static final int NAME_COLUMN = 0;
25 private static final String[] DUPLICATE_NAME_COLUMNS = new String[] { "name" };
26 private static final String[][] DUPLICATE_NAMES = new String[][] {
39 mIsDuplicateName = new HashMap<String, Boolean> ();
40 mDuplicateNameCursor = new MatrixCursor(DUPLICATE_NAME_COLUMNS);
41 for (int i = 0; i < DUPLICATE_NAMES.length; i++) {
42 mDuplicateNameCursor.addRow(DUPLICATE_NAMES[i]);
45 mIsDuplicateNameExpected = new HashMap<String, Boolean> ();
46 mIsDuplicateNameExpected.put("Pepper Pots", true);
47 mIsDuplicateNameExpected.put("Green Goblin", false);
48 mIsDuplicateNameExpected.put("Peter Parker", false);
49 mIsDuplicateNameExpected.put("Silver Surfer", false);
50 mIsDuplicateNameExpected.put("John Jameson", true);
54 public void tearDown() {
55 mDuplicateNameCursor.close();
59 public void testCheckForDuplicateNames() {
60 Utils.checkForDuplicateNames(mIsDuplicateName, mDuplicateNameCursor, NAME_COLUMN);
61 assertEquals(mIsDuplicateName, mIsDuplicateNameExpected);