summaryrefslogtreecommitdiffstats
path: root/tests/CoreTests
diff options
context:
space:
mode:
authorNeal Nguyen <tommyn@google.com>2010-01-07 10:14:05 -0800
committerNeal Nguyen <tommyn@google.com>2010-01-27 13:36:38 -0800
commit22e31e5b609136d5bf7d77b1dccd6b042b83ebdf (patch)
treed42bca2b4b406fa1fda149365985a25e2692b2dc /tests/CoreTests
parent9ecaf8b8da6a556be6143b74b9e77cf4e08ff1e8 (diff)
downloadframeworks_base-22e31e5b609136d5bf7d77b1dccd6b042b83ebdf.zip
frameworks_base-22e31e5b609136d5bf7d77b1dccd6b042b83ebdf.tar.gz
frameworks_base-22e31e5b609136d5bf7d77b1dccd6b042b83ebdf.tar.bz2
Moving framework core tests closer to their source files.
Phase 2 of test case cleanup; distributing CoreTests files closer to their respective sources under frameworks.
Diffstat (limited to 'tests/CoreTests')
-rw-r--r--tests/CoreTests/android/content/ObserverNodeTest.java92
-rw-r--r--tests/CoreTests/android/content/SyncStorageEngineTest.java66
-rw-r--r--tests/CoreTests/android/core/AbstractJDBCDriverTest.java211
-rw-r--r--tests/CoreTests/android/core/AtParserTest.java348
-rw-r--r--tests/CoreTests/android/core/CoreTests.java65
-rw-r--r--tests/CoreTests/android/core/JavaTests.java86
-rw-r--r--tests/CoreTests/android/core/RecurrenceSetTest.java82
-rw-r--r--tests/CoreTests/android/core/SQLiteJDBCDriverTest.java137
-rw-r--r--tests/CoreTests/android/database/MatrixCursorTest.java152
-rw-r--r--tests/CoreTests/android/location/LocationManagerProximityTest.java282
-rw-r--r--tests/CoreTests/android/location/LocationTest.java230
-rw-r--r--tests/CoreTests/android/util/DayOfMonthCursorTest.java157
-rw-r--r--tests/CoreTests/android/util/FloatMathTest.java55
-rw-r--r--tests/CoreTests/android/util/MonthDisplayHelperTest.java211
-rw-r--r--tests/CoreTests/android/util/StateSetTest.java182
-rw-r--r--tests/CoreTests/android/view/FocusFinderTest.java576
-rw-r--r--tests/CoreTests/android/view/ViewGroupAttributesTest.java83
-rw-r--r--tests/CoreTests/android/webkit/UrlInterceptRegistryTest.java88
-rw-r--r--tests/CoreTests/com/android/internal/telephony/ATResponseParserTest.java113
-rw-r--r--tests/CoreTests/com/android/internal/telephony/AdnRecordTest.java176
-rw-r--r--tests/CoreTests/com/android/internal/telephony/GsmAlphabetTest.java310
-rw-r--r--tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java475
-rw-r--r--tests/CoreTests/com/android/internal/telephony/PhoneNumberWatcherTest.java65
-rw-r--r--tests/CoreTests/com/android/internal/telephony/SMSDispatcherTest.java105
-rw-r--r--tests/CoreTests/com/android/internal/telephony/SimPhoneBookTest.java106
-rw-r--r--tests/CoreTests/com/android/internal/telephony/SimSmsTest.java60
-rw-r--r--tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java87
-rw-r--r--tests/CoreTests/com/android/internal/telephony/TelephonyTests.java54
-rw-r--r--tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java219
-rw-r--r--tests/CoreTests/com/android/internal/telephony/TestPhoneNotifier.java53
-rw-r--r--tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java1938
-rw-r--r--tests/CoreTests/com/android/internal/telephony/gsm/GSMTestHandler.java118
-rw-r--r--tests/CoreTests/com/android/internal/util/PredicatesTest.java74
33 files changed, 0 insertions, 7056 deletions
diff --git a/tests/CoreTests/android/content/ObserverNodeTest.java b/tests/CoreTests/android/content/ObserverNodeTest.java
deleted file mode 100644
index 68cc75b..0000000
--- a/tests/CoreTests/android/content/ObserverNodeTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.content;
-
-import java.util.ArrayList;
-
-import android.content.ContentService.ObserverCall;
-import android.content.ContentService.ObserverNode;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-public class ObserverNodeTest extends AndroidTestCase {
- static class TestObserver extends ContentObserver {
- public TestObserver() {
- super(new Handler());
- }
- }
-
- public void testUri() {
- ObserverNode root = new ObserverNode("");
- Uri[] uris = new Uri[] {
- Uri.parse("content://c/a/"),
- Uri.parse("content://c/"),
- Uri.parse("content://x/"),
- Uri.parse("content://c/b/"),
- Uri.parse("content://c/a/a1/1/"),
- Uri.parse("content://c/a/a1/2/"),
- Uri.parse("content://c/b/1/"),
- Uri.parse("content://c/b/2/"),
- };
-
- int[] nums = new int[] {4, 7, 1, 4, 2, 2, 3, 3};
-
- // special case
- root.addObserver(uris[0], new TestObserver().getContentObserver(), false);
- for(int i = 1; i < uris.length; i++) {
- root.addObserver(uris[i], new TestObserver().getContentObserver(), true);
- }
-
- ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>();
-
- for (int i = nums.length - 1; i >=0; --i) {
- root.collectObservers(uris[i], 0, null, false, calls);
- assertEquals(nums[i], calls.size());
- calls.clear();
- }
- }
-
- public void testUriNotNotify() {
- ObserverNode root = new ObserverNode("");
- Uri[] uris = new Uri[] {
- Uri.parse("content://c/"),
- Uri.parse("content://x/"),
- Uri.parse("content://c/a/"),
- Uri.parse("content://c/b/"),
- Uri.parse("content://c/a/1/"),
- Uri.parse("content://c/a/2/"),
- Uri.parse("content://c/b/1/"),
- Uri.parse("content://c/b/2/"),
- };
- int[] nums = new int[] {7, 1, 3, 3, 1, 1, 1, 1};
-
- for(int i = 0; i < uris.length; i++) {
- root.addObserver(uris[i], new TestObserver().getContentObserver(), false);
- }
-
- ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>();
-
- for (int i = uris.length - 1; i >=0; --i) {
- root.collectObservers(uris[i], 0, null, false, calls);
- assertEquals(nums[i], calls.size());
- calls.clear();
- }
- }
-}
diff --git a/tests/CoreTests/android/content/SyncStorageEngineTest.java b/tests/CoreTests/android/content/SyncStorageEngineTest.java
deleted file mode 100644
index 533338e..0000000
--- a/tests/CoreTests/android/content/SyncStorageEngineTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.content;
-
-import android.test.AndroidTestCase;
-import android.test.RenamingDelegatingContext;
-import android.test.mock.MockContext;
-import android.test.mock.MockContentResolver;
-import android.accounts.Account;
-
-public class SyncStorageEngineTest extends AndroidTestCase {
-
- /**
- * Test that we handle the case of a history row being old enough to purge before the
- * correcponding sync is finished. This can happen if the clock changes while we are syncing.
- */
- public void testPurgeActiveSync() throws Exception {
- final Account account = new Account("a@example.com", "example.type");
- final String authority = "testprovider";
-
- MockContentResolver mockResolver = new MockContentResolver();
-
- SyncStorageEngine engine = SyncStorageEngine.newTestInstance(
- new TestContext(mockResolver, getContext()));
-
- long time0 = 1000;
- long historyId = engine.insertStartSyncEvent(
- account, authority, time0, SyncStorageEngine.SOURCE_LOCAL);
- long time1 = time0 + SyncStorageEngine.MILLIS_IN_4WEEKS * 2;
- engine.stopSyncEvent(historyId, time1 - time0, "yay", 0, 0);
- }
-}
-
-class TestContext extends ContextWrapper {
-
- ContentResolver mResolver;
-
- public TestContext(ContentResolver resolver, Context realContext) {
- super(new RenamingDelegatingContext(new MockContext(), realContext, "test."));
- mResolver = resolver;
- }
-
- @Override
- public void enforceCallingOrSelfPermission(String permission, String message) {
- }
-
-
- @Override
- public ContentResolver getContentResolver() {
- return mResolver;
- }
-}
diff --git a/tests/CoreTests/android/core/AbstractJDBCDriverTest.java b/tests/CoreTests/android/core/AbstractJDBCDriverTest.java
deleted file mode 100644
index e381a5e..0000000
--- a/tests/CoreTests/android/core/AbstractJDBCDriverTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.core;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Tests for the most commonly used methods of sql like creating a connection,
- * inserting, selecting, updating.
- */
-public abstract class AbstractJDBCDriverTest extends TestCase {
-
- @MediumTest
- public void testJDBCDriver() throws Exception {
- Connection firstConnection = null;
- Connection secondConnection = null;
- File dbFile = getDbFile();
- String connectionURL = getConnectionURL();
- Statement firstStmt = null;
- Statement secondStmt = null;
- try {
- Class.forName(getJDBCDriverClassName());
- firstConnection = DriverManager.getConnection(connectionURL);
- secondConnection = DriverManager.getConnection(connectionURL);
-
- String[] ones = {"hello!", "goodbye"};
- short[] twos = {10, 20};
- String[] onesUpdated = new String[ones.length];
- for (int i = 0; i < ones.length; i++) {
- onesUpdated[i] = ones[i] + twos[i];
- }
- firstStmt = firstConnection.createStatement();
- firstStmt.execute("create table tbl1(one varchar(10), two smallint)");
- secondStmt = secondConnection.createStatement();
-
- autoCommitInsertSelectTest(firstStmt, ones, twos);
- updateSelectCommitSelectTest(firstStmt, secondStmt, ones, onesUpdated, twos);
- updateSelectRollbackSelectTest(firstStmt, secondStmt, onesUpdated, ones, twos);
- } finally {
- closeConnections(firstConnection, secondConnection, dbFile, firstStmt, secondStmt);
- }
- }
-
- protected abstract String getJDBCDriverClassName();
- protected abstract String getConnectionURL();
- protected abstract File getDbFile();
-
- private void closeConnections(Connection firstConnection, Connection secondConnection,
- File dbFile, Statement firstStmt, Statement secondStmt) {
- String failText = null;
- try {
- if (firstStmt != null) {
- firstStmt.execute("drop table tbl1");
- }
- } catch (SQLException e) {
- failText = e.getLocalizedMessage();
- }
- try {
- if (firstStmt != null) {
- firstStmt.close();
- }
- } catch (SQLException e) {
- failText = e.getLocalizedMessage();
- }
- try {
- if (firstConnection != null) {
- firstConnection.close();
- }
- } catch (SQLException e) {
- failText = e.getLocalizedMessage();
- }
- try {
- if (secondStmt != null) {
- secondStmt.close();
- }
- } catch (SQLException e) {
- failText = e.getLocalizedMessage();
- }
- try {
- if (secondConnection != null) {
- secondConnection.close();
- }
- } catch (SQLException e) {
- failText = e.getLocalizedMessage();
- }
- dbFile.delete();
- assertNull(failText, failText);
- }
-
- /**
- * Inserts the values from 'ones' with the values from 'twos' into 'tbl1'
- * @param stmt the statement to use for the inserts.
- * @param ones the string values to insert into tbl1.
- * @param twos the corresponding numerical values to insert into tbl1.
- * @throws SQLException in case of a problem during insert.
- */
- private void autoCommitInsertSelectTest(Statement stmt, String[] ones,
- short[] twos) throws SQLException {
- for (int i = 0; i < ones.length; i++) {
- stmt.execute("insert into tbl1 values('" + ones[i] + "'," + twos[i]
- + ")");
- }
- assertAllFromTbl1(stmt, ones, twos);
- }
-
- /**
- * Asserts that all values that where added to tbl1 are actually in tbl1.
- * @param stmt the statement to use for the select.
- * @param ones the string values that where added.
- * @param twos the numerical values that where added.
- * @throws SQLException in case of a problem during select.
- */
- private void assertAllFromTbl1(Statement stmt, String[] ones, short[] twos)
- throws SQLException {
- ResultSet rs = stmt.executeQuery("select * from tbl1");
- int i = 0;
- for (; rs.next(); i++) {
- assertTrue(i < ones.length);
- assertEquals(ones[i], rs.getString("one"));
- assertEquals(twos[i], rs.getShort("two"));
- }
- assertEquals(i, ones.length);
- }
-
- /**
- * Tests the results of an update followed bz a select on a diffrent statement.
- * After that the first statement commits its update. and now the second
- * statement should also be able to see the changed values in a select.
- * @param firstStmt the statement to use for the update and commit.
- * @param secondStmt the statement that should be used to check if the commit works
- * @param ones the original string values.
- * @param onesUpdated the updated string values.
- * @param twos the numerical values.
- * @throws SQLException in case of a problem during any of the executed commands.
- */
- private void updateSelectCommitSelectTest(Statement firstStmt,
- Statement secondStmt, String[] ones, String[] onesUpdated,
- short[] twos) throws SQLException {
- firstStmt.getConnection().setAutoCommit(false);
- try {
- updateOnes(firstStmt, onesUpdated, twos);
- assertAllFromTbl1(secondStmt, ones, twos);
- firstStmt.getConnection().commit();
- assertAllFromTbl1(secondStmt, onesUpdated, twos);
- } finally {
- firstStmt.getConnection().setAutoCommit(true);
- }
- }
-
- /**
- * Tests if an update followed by a select works. After that a rollback will
- * be made and again a select should show that the rollback worked.
- * @param firstStmt the statement to use for the update and the rollback
- * @param secondStmt the statement to use for checking if the rollback worked as intended.
- * @param ones the original string values.
- * @param onesUpdated the updated string values.
- * @param twos the nomerical values.
- * @throws SQLException in case of a problem during any command.
- */
- private void updateSelectRollbackSelectTest(Statement firstStmt,
- Statement secondStmt, String[] ones, String[] onesUpdated,
- short[] twos) throws SQLException {
- firstStmt.getConnection().setAutoCommit(false);
- try {
- updateOnes(firstStmt, onesUpdated, twos);
- assertAllFromTbl1(secondStmt, ones, twos);
- firstStmt.getConnection().rollback();
- assertAllFromTbl1(secondStmt, ones, twos);
- } finally {
- firstStmt.getConnection().setAutoCommit(true);
- }
- }
-
- /**
- * updates the sring values. the original values are stored in 'ones'
- * and the updated values in 'ones_updated'
- * @param stmt the statement to use for the update.
- * @param onesUpdated the new string values.
- * @param twos the numerical values.
- * @throws SQLException in case of a problem during update.
- */
- private void updateOnes(Statement stmt, String[] onesUpdated, short[] twos)
- throws SQLException {
- for (int i = 0; i < onesUpdated.length; i++) {
- stmt.execute("UPDATE tbl1 SET one = '" + onesUpdated[i]
- + "' WHERE two = " + twos[i]);
- }
- }
-}
diff --git a/tests/CoreTests/android/core/AtParserTest.java b/tests/CoreTests/android/core/AtParserTest.java
deleted file mode 100644
index 09cb6e9..0000000
--- a/tests/CoreTests/android/core/AtParserTest.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.core;
-
-import android.bluetooth.AtCommandHandler;
-import android.bluetooth.AtCommandResult;
-import android.bluetooth.AtParser;
-
-import java.util.*;
-import junit.framework.*;
-
-public class AtParserTest extends TestCase {
-
- /* An AtCommandHandler instrumented for testing purposes
- */
- private class HandlerTest extends AtCommandHandler {
- boolean mBasicCalled, mActionCalled, mReadCalled, mTestCalled,
- mSetCalled;
- int mBasicReturn, mActionReturn, mReadReturn, mTestReturn, mSetReturn;
- Object[] mSetArgs;
- String mBasicArgs;
-
- HandlerTest() {
- this(AtCommandResult.ERROR, AtCommandResult.ERROR,
- AtCommandResult.ERROR, AtCommandResult.ERROR,
- AtCommandResult.ERROR);
- }
-
- HandlerTest(int a, int b, int c, int d, int e) {
- mBasicReturn = a;
- mActionReturn = b;
- mReadReturn = c;
- mSetReturn = d;
- mTestReturn = e;
- reset();
- }
- public void reset() {
- mBasicCalled = false;
- mActionCalled = false;
- mReadCalled = false;
- mSetCalled = false;
- mTestCalled = false;
- mSetArgs = null;
- mBasicArgs = null;
- }
- public boolean wasCalled() { // helper
- return mBasicCalled || mActionCalled || mReadCalled ||
- mTestCalled || mSetCalled;
- }
- @Override
- public AtCommandResult handleBasicCommand(String args) {
- mBasicCalled = true;
- mBasicArgs = args;
- return new AtCommandResult(mBasicReturn);
- }
- @Override
- public AtCommandResult handleActionCommand() {
- mActionCalled = true;
- return new AtCommandResult(mActionReturn);
- }
- @Override
- public AtCommandResult handleReadCommand() {
- mReadCalled = true;
- return new AtCommandResult(mReadReturn);
- }
- @Override
- public AtCommandResult handleSetCommand(Object[] args) {
- mSetCalled = true;
- mSetArgs = args;
- return new AtCommandResult(mSetReturn);
- }
- @Override
- public AtCommandResult handleTestCommand() {
- mTestCalled = true;
- return new AtCommandResult(mTestReturn);
- }
- }
-
- private AtParser mParser;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mParser = new AtParser();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-
- /* Test that the right method is being called
- */
-/* public void testBasic1() throws Exception {
- HandlerTest D = new HandlerTest(0, 1, 1, 1, 1);
- HandlerTest A = new HandlerTest(0, 1, 1, 1, 1);
- mParser.register('D', D);
- mParser.register('A', A);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process(" A T D = ? T 1 2 3 4 ").toStrings()));
- assertTrue(D.mBasicCalled);
- assertFalse(D.mActionCalled);
- assertFalse(D.mTestCalled);
- assertFalse(D.mSetCalled);
- assertFalse(D.mReadCalled);
- assertFalse(A.wasCalled());
- assertEquals("=?T1234", D.mBasicArgs);
- }
-*/
- /* Test some crazy strings
- *//*
- public void testBasic2() throws Exception {
- HandlerTest A = new HandlerTest(0, 1, 1, 1, 1);
- mParser.register('A', A);
-
- assertTrue(Arrays.equals(
- new String[]{},
- mParser.process(" ").toStrings()));
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process(" a T a t \"\" 1 2 3 a 4 ")
- .toStrings()));
- assertEquals("T\"\"123A4", A.mBasicArgs);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process(" a T a t \"foo BaR12Z\" 1 2 3 a 4 ")
- .toStrings()));
- assertEquals("T\"foo BaR12Z\"123A4", A.mBasicArgs);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("ATA\"").toStrings()));
- assertEquals("\"\"", A.mBasicArgs);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("ATA\"a").toStrings()));
- assertEquals("\"a\"", A.mBasicArgs);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("ATa\" ").toStrings()));
- assertEquals("\" \"", A.mBasicArgs);
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("ATA \"one \" two \"t hr ee ")
- .toStrings()));
- assertEquals("\"one \"TWO\"t hr ee \"", A.mBasicArgs);
- }*/
-
- /* Simple extended commands
- *//*
- public void testExt1() throws Exception {
- HandlerTest A = new HandlerTest(1, 0, 0, 0, 0);
- mParser.register("+A", A);
-
- assertTrue(Arrays.equals(
- new String[]{"ERROR"},
- mParser.process("AT+B").toStrings()));
- assertFalse(A.wasCalled());
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+A").toStrings()));
- assertTrue(A.mActionCalled);
- A.mActionCalled = false;
- assertFalse(A.wasCalled());
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+A=").toStrings()));
- assertTrue(A.mSetCalled);
- A.mSetCalled = false;
- assertFalse(A.wasCalled());
- assertEquals(1, A.mSetArgs.length);
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+A=?").toStrings()));
- assertTrue(A.mTestCalled);
- A.mTestCalled = false;
- assertFalse(A.wasCalled());
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+A?").toStrings()));
- assertTrue(A.mReadCalled);
- A.mReadCalled = false;
- assertFalse(A.wasCalled());
- A.reset();
- }
-*/
-
-
- /* Test chained commands
- *//*
- public void testChain1() throws Exception {
- HandlerTest A = new HandlerTest(0, 1, 1, 1, 1);
- HandlerTest B = new HandlerTest(1, 0, 0, 0, 0);
- HandlerTest C = new HandlerTest(1, 1, 1, 1, 1);
- mParser.register('A', A);
- mParser.register("+B", B);
- mParser.register("+C", C);
-
- assertTrue(Arrays.equals(
- new String[]{"ERROR"},
- mParser.process("AT+B;+C").toStrings()));
- assertTrue(B.mActionCalled);
- assertTrue(C.mActionCalled);
- B.reset();
- C.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"ERROR"},
- mParser.process("AT+C;+B").toStrings()));
- assertFalse(B.wasCalled());
- assertTrue(C.mActionCalled);
- B.reset();
- C.reset();
- }*/
-
- /* Test Set command
- *//*
- public void testSet1() throws Exception {
- HandlerTest A = new HandlerTest(1, 1, 1, 0, 1);
- mParser.register("+AAAA", A);
- Object[] expectedResult;
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=1").toStrings()));
- expectedResult = new Object[]{(Integer)1};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=1,2,3").toStrings()));
- expectedResult = new Object[]{(Integer)1, (Integer)2, (Integer)3};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=3,0,0,1").toStrings()));
- expectedResult = new Object[]{(Integer)3, (Integer)0, (Integer)0,
- (Integer)1};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=\"foo\",1,\"b,ar").toStrings()));
- expectedResult = new Object[]{"\"foo\"", 1, "\"b,ar\""};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=").toStrings()));
- expectedResult = new Object[]{""};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=,").toStrings()));
- expectedResult = new Object[]{"", ""};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=,,,").toStrings()));
- expectedResult = new Object[]{"", "", "", ""};
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("AT+AAAA=,1,,\"foo\",").toStrings()));
- expectedResult = new Object[]{"", 1, "", "\"foo\"", ""};
- assertEquals(5, A.mSetArgs.length);
- assertTrue(Arrays.equals(expectedResult, A.mSetArgs));
- A.reset();
- }*/
-
- /* Test repeat command "A/"
- *//*
- public void testRepeat() throws Exception {
- HandlerTest A = new HandlerTest(0, 0, 0, 0, 0);
- mParser.register('A', A);
-
- // Try repeated command on fresh parser
- assertTrue(Arrays.equals(
- new String[]{},
- mParser.process("A/").toStrings()));
- assertFalse(A.wasCalled());
- A.reset();
-
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("ATA").toStrings()));
- assertTrue(A.mBasicCalled);
- assertEquals("", A.mBasicArgs);
- A.reset();
-
- // Now repeat the command
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("A/").toStrings()));
- assertTrue(A.mBasicCalled);
- assertEquals("", A.mBasicArgs);
- A.reset();
-
- // Multiple repeats
- assertTrue(Arrays.equals(
- new String[]{"OK"},
- mParser.process("A/").toStrings()));
- assertTrue(A.mBasicCalled);
- assertEquals("", A.mBasicArgs);
- A.reset();
-
- }*/
-}
diff --git a/tests/CoreTests/android/core/CoreTests.java b/tests/CoreTests/android/core/CoreTests.java
deleted file mode 100644
index 442fe0f..0000000
--- a/tests/CoreTests/android/core/CoreTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.core;
-
-import com.android.internal.telephony.TelephonyTests;
-
-import junit.framework.TestSuite;
-
-import android.graphics.ColorStateListTest;
-import android.location.LocationManagerProximityTest;
-import android.location.LocationTest;
-import android.test.AndroidTestRunnerTest;
-import android.test.InstrumentationTestRunnerTest;
-import android.util.*;
-import android.view.FocusFinderTest;
-import android.view.ViewGroupAttributesTest;
-import android.webkit.*;
-
-public class CoreTests extends TestSuite {
-
- /**
- * To run these tests:
- * $ mmm java/tests && adb sync
- * $ adb shell am instrument -w \
- * -e class android.core.CoreTests \
- * android.core/android.test.InstrumentationTestRunner
- */
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(CoreTests.class.getName());
-
- // Re-enable StateListDrawableTest when we are running in the
- // framework-test directory which allows access to package private
- // access for MockView
- // suite.addTestSuite(StateListDrawableTest.class);
- suite.addTestSuite(DayOfMonthCursorTest.class);
- suite.addTestSuite(MonthDisplayHelperTest.class);
- suite.addTestSuite(StateSetTest.class);
- suite.addTestSuite(ColorStateListTest.class);
- suite.addTestSuite(FocusFinderTest.class);
- suite.addTestSuite(ViewGroupAttributesTest.class);
- suite.addTest(TelephonyTests.suite());
- suite.addTestSuite(FloatMathTest.class);
- suite.addTest(JavaTests.suite());
- suite.addTestSuite(LocationTest.class);
- suite.addTestSuite(LocationManagerProximityTest.class);
- suite.addTestSuite(AndroidTestRunnerTest.class);
- suite.addTestSuite(InstrumentationTestRunnerTest.class);
-
- return suite;
- }
-}
diff --git a/tests/CoreTests/android/core/JavaTests.java b/tests/CoreTests/android/core/JavaTests.java
deleted file mode 100644
index bd8cbf0..0000000
--- a/tests/CoreTests/android/core/JavaTests.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.core;
-
-import junit.framework.TestSuite;
-
-public class JavaTests {
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(JavaTests.class.getName());
-
- //Disabling until bug http://b/issue?id=1200337 is resolved
- //suite.addTestSuite(RequestAPITest.class);
- suite.addTestSuite(MathTest.class);
- suite.addTestSuite(StrictMathTest.class);
- suite.addTestSuite(HashMapPerfTest.class);
- suite.addTestSuite(TreeMapTest.class);
- suite.addTestSuite(FloatDoubleTest.class);
- suite.addTestSuite(Sha1Test.class);
- suite.addTestSuite(NIOTest.class);
- suite.addTestSuite(ReflectArrayTest.class);
- //Commenting out until we find a better way to exclude from continuous testing.
- //suite.addTestSuite(URLTest.class);
- suite.addTestSuite(URITest.class);
- suite.addTestSuite(RegexTest.class);
- suite.addTestSuite(HashMapTest.class);
- suite.addTestSuite(ArrayListTest.class);
- suite.addTestSuite(BooleanTest.class);
- suite.addTestSuite(StringTest.class);
- suite.addTestSuite(BufferedReaderTest.class);
- suite.addTestSuite(CharArrayReaderTest.class);
- suite.addTestSuite(PushbackReaderTest.class);
- suite.addTestSuite(StringReaderTest.class);
- suite.addTestSuite(StreamTokenizerTest.class);
- suite.addTestSuite(ByteArrayInputStreamTest.class);
- suite.addTestSuite(DataInputStreamTest.class);
- suite.addTestSuite(BufferedInputStreamTest.class);
- suite.addTestSuite(PushbackInputStreamTest.class);
- suite.addTestSuite(ByteArrayOutputStreamTest.class);
- suite.addTestSuite(DataOutputStreamTest.class);
- suite.addTestSuite(BufferedOutputStreamTest.class);
- suite.addTestSuite(CharArrayWriterTest.class);
- suite.addTestSuite(StringWriterTest.class);
- suite.addTestSuite(PrintWriterTest.class);
- suite.addTestSuite(BufferedWriterTest.class);
- suite.addTestSuite(ClassTest.class);
- //To be unccommented when Bug #799327 is fixed.
- //suite.addTestSuite(ClassLoaderTest.class);
- suite.addTestSuite(LineNumberReaderTest.class);
- suite.addTestSuite(InputStreamReaderTest.class);
- suite.addTestSuite(OutputStreamWriterTest.class);
- suite.addTestSuite(EnumTest.class);
- suite.addTestSuite(ParseIntTest.class);
- suite.addTestSuite(PipedStreamTest.class);
- suite.addTestSuite(LocaleTest.class);
- //Commenting out until we find a better way to exclude from continuous testing.
- //suite.addTestSuite(InetAddrTest.class);
- suite.addTestSuite(SocketTest.class);
- suite.addTestSuite(ChecksumTest.class);
- suite.addTestSuite(DeflateTest.class);
- suite.addTestSuite(ZipStreamTest.class);
- suite.addTestSuite(GZIPStreamTest.class);
- suite.addTestSuite(ZipFileTest.class);
- suite.addTestSuite(FileTest.class);
- suite.addTestSuite(SQLiteJDBCDriverTest.class);
- suite.addTestSuite(AtParserTest.class);
- suite.addTestSuite(DatagramTest.class);
- suite.addTestSuite(CryptoTest.class);
- suite.addTestSuite(MiscRegressionTest.class);
-
- return suite;
- }
-}
diff --git a/tests/CoreTests/android/core/RecurrenceSetTest.java b/tests/CoreTests/android/core/RecurrenceSetTest.java
deleted file mode 100644
index cee324c..0000000
--- a/tests/CoreTests/android/core/RecurrenceSetTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2009 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 android.core;
-
-import android.content.ContentValues;
-import android.pim.ICalendar;
-import android.pim.RecurrenceSet;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-import android.provider.Calendar;
-import junit.framework.TestCase;
-
-/**
- * Test some pim.RecurrenceSet functionality.
- */
-public class RecurrenceSetTest extends TestCase {
-
- // Test a recurrence
- @SmallTest
- public void testRecurrenceSet0() throws Exception {
- String recurrence = "DTSTART;TZID=America/New_York:20080221T070000\n"
- + "DTEND;TZID=America/New_York:20080221T190000\n"
- + "RRULE:FREQ=DAILY;UNTIL=20080222T000000Z\n"
- + "EXDATE:20080222T120000Z";
- verifyPopulateContentValues(recurrence, "FREQ=DAILY;UNTIL=20080222T000000Z", null,
- null, "20080222T120000Z", 1203595200000L, "America/New_York", "P43200S", 0);
- }
-
- // Test 1 day all-day event
- @SmallTest
- public void testRecurrenceSet1() throws Exception {
- String recurrence = "DTSTART;VALUE=DATE:20090821\nDTEND;VALUE=DATE:20090822\n"
- + "RRULE:FREQ=YEARLY;WKST=SU";
- verifyPopulateContentValues(recurrence, "FREQ=YEARLY;WKST=SU", null,
- null, null, 1250812800000L, null, "P1D", 1);
- }
-
- // Test 2 day all-day event
- @SmallTest
- public void testRecurrenceSet2() throws Exception {
- String recurrence = "DTSTART;VALUE=DATE:20090821\nDTEND;VALUE=DATE:20090823\n"
- + "RRULE:FREQ=YEARLY;WKST=SU";
- verifyPopulateContentValues(recurrence, "FREQ=YEARLY;WKST=SU", null,
- null, null, 1250812800000L, null, "P2D", 1);
- }
-
- // run populateContentValues and verify the results
- private void verifyPopulateContentValues(String recurrence, String rrule, String rdate,
- String exrule, String exdate, long dtstart, String tzid, String duration, int allDay)
- throws ICalendar.FormatException {
- ICalendar.Component recurrenceComponent =
- new ICalendar.Component("DUMMY", null /* parent */);
- ICalendar.parseComponent(recurrenceComponent, recurrence);
- ContentValues values = new ContentValues();
- RecurrenceSet.populateContentValues(recurrenceComponent, values);
- Log.d("KS", "values " + values);
-
- assertEquals(rrule, values.get(android.provider.Calendar.Events.RRULE));
- assertEquals(rdate, values.get(android.provider.Calendar.Events.RDATE));
- assertEquals(exrule, values.get(android.provider.Calendar.Events.EXRULE));
- assertEquals(exdate, values.get(android.provider.Calendar.Events.EXDATE));
- assertEquals(dtstart, (long) values.getAsLong(Calendar.Events.DTSTART));
- assertEquals(tzid, values.get(android.provider.Calendar.Events.EVENT_TIMEZONE));
- assertEquals(duration, values.get(android.provider.Calendar.Events.DURATION));
- assertEquals(allDay,
- (int) values.getAsInteger(android.provider.Calendar.Events.ALL_DAY));
- }
-}
diff --git a/tests/CoreTests/android/core/SQLiteJDBCDriverTest.java b/tests/CoreTests/android/core/SQLiteJDBCDriverTest.java
deleted file mode 100644
index eec82aa..0000000
--- a/tests/CoreTests/android/core/SQLiteJDBCDriverTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.core;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Minimal test for JDBC driver
- */
-public class SQLiteJDBCDriverTest extends AbstractJDBCDriverTest {
-
- private File dbFile;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- dbFile = File.createTempFile("sqliteTestDB", null);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if(dbFile != null) {
- dbFile.delete();
- }
- super.tearDown();
- }
-
- @Override
- protected String getConnectionURL() {
- return "jdbc:sqlite:/" + dbFile;
- }
-
- @Override
- protected File getDbFile() {
- return dbFile;
- }
-
- @Override
- protected String getJDBCDriverClassName() {
- return "SQLite.JDBCDriver";
- }
-
- // Regression test for (Noser) #255: PreparedStatement.executeUpdate results
- // in VM crashing with SIGABRT.
- @MediumTest
- public void test_connection3() throws Exception {
- PreparedStatement prst = null;
- Statement st = null;
- Connection conn = null;
- try {
- Class.forName("SQLite.JDBCDriver").newInstance();
- if (dbFile.exists()) {
- dbFile.delete();
- }
- conn = DriverManager.getConnection("jdbc:sqlite:/"
- + dbFile.getPath());
- assertNotNull(conn);
-
- // create table
- st = conn.createStatement();
- String sql = "CREATE TABLE zoo (ZID INTEGER NOT NULL, family VARCHAR (20) NOT NULL, name VARCHAR (20) NOT NULL, PRIMARY KEY(ZID) )";
- st.executeUpdate(sql);
-
- String update = "update zoo set family = ? where name = ?;";
- prst = conn.prepareStatement(update);
- prst.setString(1, "cat");
- prst.setString(2, "Yasha");
- // st = conn.createStatement();
- // st.execute("select * from zoo where family = 'cat'");
- // ResultSet rs = st.getResultSet();
- // assertEquals(0, getCount(rs));
- prst.executeUpdate();
- // st.execute("select * from zoo where family = 'cat'");
- // ResultSet rs1 = st.getResultSet();
- // assertEquals(1, getCount(rs1));
- try {
- prst = conn.prepareStatement("");
- prst.execute();
- fail("SQLException is not thrown");
- } catch (SQLException e) {
- // expected
- }
-
- try {
- conn.prepareStatement(null);
- fail("NPE is not thrown");
- } catch (Exception e) {
- // expected
- }
- try {
- st = conn.createStatement();
- st.execute("drop table if exists zoo");
-
- } catch (SQLException e) {
- fail("Couldn't drop table: " + e.getMessage());
- } finally {
- try {
- st.close();
- conn.close();
- } catch (SQLException ee) {
- }
- }
- } finally {
- try {
- if (prst != null) {
- prst.close();
- }
- if (st != null) {
- st.close();
- }
- } catch (SQLException ee) {
- }
- }
-
- }
-
-}
diff --git a/tests/CoreTests/android/database/MatrixCursorTest.java b/tests/CoreTests/android/database/MatrixCursorTest.java
deleted file mode 100644
index cddc6c4..0000000
--- a/tests/CoreTests/android/database/MatrixCursorTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.database;
-
-import junit.framework.TestCase;
-
-import java.util.*;
-
-public class MatrixCursorTest extends TestCase {
-
- public void testEmptyCursor() {
- Cursor cursor = new MatrixCursor(new String[] { "a" });
- assertEquals(0, cursor.getCount());
- }
-
- public void testNullValue() {
- MatrixCursor cursor = new MatrixCursor(new String[] { "a" });
- cursor.newRow().add(null);
- cursor.moveToNext();
- assertTrue(cursor.isNull(0));
- assertNull(cursor.getString(0));
- assertEquals(0, cursor.getShort(0));
- assertEquals(0, cursor.getInt(0));
- assertEquals(0L, cursor.getLong(0));
- assertEquals(0.0f, cursor.getFloat(0));
- assertEquals(0.0d, cursor.getDouble(0));
- }
-
- public void testMatrixCursor() {
- MatrixCursor cursor = newMatrixCursor();
-
- cursor.newRow()
- .add("a")
- .add(1)
- .add(2)
- .add(3)
- .add(4)
- .add(5);
-
- cursor.moveToNext();
-
- checkValues(cursor);
-
- cursor.newRow()
- .add("a")
- .add("1")
- .add("2")
- .add("3")
- .add("4")
- .add("5");
-
- cursor.moveToNext();
- checkValues(cursor);
-
- cursor.moveToPrevious();
- checkValues(cursor);
- }
-
- public void testAddArray() {
- MatrixCursor cursor = newMatrixCursor();
-
- cursor.addRow(new Object[] { "a", 1, 2, 3, 4, 5 });
- cursor.moveToNext();
- checkValues(cursor);
-
- try {
- cursor.addRow(new Object[0]);
- fail();
- } catch (IllegalArgumentException e) { /* expected */ }
- }
-
- public void testAddIterable() {
- MatrixCursor cursor = newMatrixCursor();
-
- cursor.addRow(Arrays.asList("a", 1, 2, 3, 4, 5));
- cursor.moveToNext();
- checkValues(cursor);
-
- try {
- cursor.addRow(Collections.emptyList());
- fail();
- } catch (IllegalArgumentException e) { /* expected */ }
-
- try {
- cursor.addRow(Arrays.asList("a", 1, 2, 3, 4, 5, "Too many!"));
- fail();
- } catch (IllegalArgumentException e) { /* expected */ }
- }
-
- public void testAddArrayList() {
- MatrixCursor cursor = newMatrixCursor();
-
- cursor.addRow(new NonIterableArrayList<Object>(
- Arrays.asList("a", 1, 2, 3, 4, 5)));
- cursor.moveToNext();
- checkValues(cursor);
-
- try {
- cursor.addRow(new NonIterableArrayList<Object>());
- fail();
- } catch (IllegalArgumentException e) { /* expected */ }
-
- try {
- cursor.addRow(new NonIterableArrayList<Object>(
- Arrays.asList("a", 1, 2, 3, 4, 5, "Too many!")));
- fail();
- } catch (IllegalArgumentException e) { /* expected */ }
- }
-
- static class NonIterableArrayList<T> extends ArrayList<T> {
-
- NonIterableArrayList() {}
-
- NonIterableArrayList(Collection<? extends T> ts) {
- super(ts);
- }
-
- @Override
- public Iterator<T> iterator() {
- throw new AssertionError();
- }
- }
-
- private MatrixCursor newMatrixCursor() {
- return new MatrixCursor(new String[] {
- "string", "short", "int", "long", "float", "double" });
- }
-
- private void checkValues(MatrixCursor cursor) {
- assertEquals("a", cursor.getString(0));
- assertEquals(1, cursor.getShort(1));
- assertEquals(2, cursor.getInt(2));
- assertEquals(3, cursor.getLong(3));
- assertEquals(4.0f, cursor.getFloat(4));
- assertEquals(5.0D, cursor.getDouble(5));
- }
-
-}
diff --git a/tests/CoreTests/android/location/LocationManagerProximityTest.java b/tests/CoreTests/android/location/LocationManagerProximityTest.java
deleted file mode 100644
index e82d878..0000000
--- a/tests/CoreTests/android/location/LocationManagerProximityTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc.
- *
- * 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 android.location;
-
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.location.Criteria;
-import android.location.Location;
-import android.location.LocationManager;
-import android.provider.Settings;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
-import android.util.Log;
-
-/**
- * Tests for LocationManager.addProximityAlert
- *
- * TODO: add tests for more scenarios
- *
- * To run:
- * adb shell am instrument -e class android.location.LocationManagerProximityTest \
- * -w android.core/android.test.InstrumentationTestRunner
- *
- * This test requires that the "Allow mock locations" setting be enabled.
- * To ensure reliable results, all location providers should be disabled.
- *
- */
-@Suppress
-@MediumTest
-public class LocationManagerProximityTest extends AndroidTestCase {
-
- private static final int UPDATE_LOCATION_WAIT_TIME = 1000;
- private static final int PROXIMITY_WAIT_TIME = 2000;
-
- private LocationManager mLocationManager;
- private PendingIntent mPendingIntent;
- private TestIntentReceiver mIntentReceiver;
-
- private static final String LOG_TAG = "LocationProximityTest";
-
- private static final String PROVIDER_NAME = "test";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // test that mock locations are allowed so a more descriptive error message can be logged
- if (Settings.Secure.getInt(getContext().getContentResolver(),
- Settings.Secure.ALLOW_MOCK_LOCATION, 0) == 0) {
- fail("Mock locations are currently disabled in Settings - this test requires " +
- "mock locations");
- }
-
- mLocationManager = (LocationManager) getContext().
- getSystemService(Context.LOCATION_SERVICE);
- if (mLocationManager.getProvider(PROVIDER_NAME) != null) {
- mLocationManager.removeTestProvider(PROVIDER_NAME);
- }
-
- mLocationManager.addTestProvider(PROVIDER_NAME, true, //requiresNetwork,
- false, // requiresSatellite,
- true, // requiresCell,
- false, // hasMonetaryCost,
- false, // supportsAltitude,
- false, // supportsSpeed, s
- false, // upportsBearing,
- Criteria.POWER_MEDIUM, // powerRequirement
- Criteria.ACCURACY_FINE); // accuracy
- mLocationManager.setTestProviderEnabled(PROVIDER_NAME, true);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mLocationManager.removeTestProvider(PROVIDER_NAME);
-
- if (mPendingIntent != null) {
- mLocationManager.removeProximityAlert(mPendingIntent);
- }
- if (mIntentReceiver != null) {
- getContext().unregisterReceiver(mIntentReceiver);
- }
- }
-
- /**
- * Tests basic proximity alert when entering proximity
- */
- public void testEnterProximity() throws Exception {
- doTestEnterProximity(10000);
- }
-
- /**
- * Tests proximity alert when entering proximity, with no expiration
- */
- public void testEnterProximity_noexpire() throws Exception {
- doTestEnterProximity(-1);
- }
-
- /**
- * Helper variant for testing enter proximity scenario
- * TODO: add additional parameters as more scenarios are added
- *
- * @param expiration - expiry of proximity alert
- */
- private void doTestEnterProximity(long expiration) throws Exception {
- // update location to outside proximity range
- synchronousSendLocation(30, 30);
- registerProximityListener(0, 0, 1000, expiration);
- sendLocation(0, 0);
- waitForAlert();
- assertProximityType(true);
- }
-
- /**
- * Tests basic proximity alert when exiting proximity
- */
- public void testExitProximity() throws Exception {
- // first do enter proximity scenario
- doTestEnterProximity(-1);
-
- // now update to trigger exit proximity proximity
- mIntentReceiver.clearReceivedIntents();
- sendLocation(20, 20);
- waitForAlert();
- assertProximityType(false);
- }
-
- /**
- * Registers the proximity intent receiver
- */
- private void registerProximityListener(double latitude, double longitude,
- float radius, long expiration) {
- String intentKey = "testProximity";
- Intent proximityIntent = new Intent(intentKey);
- mPendingIntent = PendingIntent.getBroadcast(getContext(), 0,
- proximityIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- mIntentReceiver = new TestIntentReceiver(intentKey);
-
- mLocationManager.addProximityAlert(latitude, longitude, radius,
- expiration, mPendingIntent);
-
- getContext().registerReceiver(mIntentReceiver,
- mIntentReceiver.getFilter());
-
- }
-
- /**
- * Blocks until proximity intent notification is received
- * @throws InterruptedException
- */
- private void waitForAlert() throws InterruptedException {
- Log.d(LOG_TAG, "Waiting for proximity update");
- synchronized (mIntentReceiver) {
- mIntentReceiver.wait(PROXIMITY_WAIT_TIME);
- }
-
- assertNotNull("Did not receive proximity alert",
- mIntentReceiver.getLastReceivedIntent());
- }
-
- /**
- * Asserts that the received intent had the enter proximity property set as
- * expected
- * @param expectedEnterProximity - true if enter proximity expected, false if
- * exit expected
- */
- private void assertProximityType(boolean expectedEnterProximity)
- throws Exception {
- boolean proximityTest = mIntentReceiver.getLastReceivedIntent().
- getBooleanExtra(LocationManager.KEY_PROXIMITY_ENTERING,
- !expectedEnterProximity);
- assertEquals("proximity alert not set to expected enter proximity value",
- expectedEnterProximity, proximityTest);
- }
-
- /**
- * Synchronous variant of sendLocation
- */
- private void synchronousSendLocation(final double latitude,
- final double longitude)
- throws InterruptedException {
- sendLocation(latitude, longitude, this);
- // wait for location to be set
- synchronized (this) {
- wait(UPDATE_LOCATION_WAIT_TIME);
- }
- }
-
- /**
- * Asynchronously update the mock location provider without notification
- */
- private void sendLocation(final double latitude, final double longitude) {
- sendLocation(latitude, longitude, null);
- }
-
- /**
- * Asynchronously update the mock location provider with given latitude and
- * longitude
- *
- * @param latitude - update location
- * @param longitude - update location
- * @param observer - optionally, object to notify when update is sent.If
- * null, no update will be sent
- */
- private void sendLocation(final double latitude, final double longitude,
- final Object observer) {
- Thread locationUpdater = new Thread() {
- @Override
- public void run() {
- Location loc = new Location(PROVIDER_NAME);
- loc.setLatitude(latitude);
- loc.setLongitude(longitude);
-
- loc.setTime(java.lang.System.currentTimeMillis());
- Log.d(LOG_TAG, "Sending update for " + PROVIDER_NAME);
- mLocationManager.setTestProviderLocation(PROVIDER_NAME, loc);
- if (observer != null) {
- synchronized (observer) {
- observer.notify();
- }
- }
- }
- };
- locationUpdater.start();
-
- }
-
- /**
- * Helper class that receives a proximity intent and notifies the main class
- * when received
- */
- private static class TestIntentReceiver extends BroadcastReceiver {
-
- private String mExpectedAction;
- private Intent mLastReceivedIntent;
-
- public TestIntentReceiver(String expectedAction) {
- mExpectedAction = expectedAction;
- mLastReceivedIntent = null;
- }
-
- public IntentFilter getFilter() {
- IntentFilter filter = new IntentFilter(mExpectedAction);
- return filter;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent != null && mExpectedAction.equals(intent.getAction())) {
- Log.d(LOG_TAG, "Intent Received: " + intent.toString());
- mLastReceivedIntent = intent;
- synchronized (this) {
- notify();
- }
- }
- }
-
- public Intent getLastReceivedIntent() {
- return mLastReceivedIntent;
- }
-
- public void clearReceivedIntents() {
- mLastReceivedIntent = null;
- }
- }
-}
diff --git a/tests/CoreTests/android/location/LocationTest.java b/tests/CoreTests/android/location/LocationTest.java
deleted file mode 100644
index 847ac7a..0000000
--- a/tests/CoreTests/android/location/LocationTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * 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 android.location;
-
-import android.test.suitebuilder.annotation.SmallTest;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for android.location.Location
- */
-@SmallTest
-public class LocationTest extends TestCase {
-
- // ***** Tests for Location.convert
- public void testConvert_DegreesToDouble(){
- String testDegreesCoord = "-80.075";
- String message;
- double result;
-
- result = Location.convert(testDegreesCoord);
- message = "degreesToDoubleTest: Double should be -80.075, actual value is " +
- String.valueOf(result);
- assertEquals(message, -80.075, result);
- }
-
- public void testConvert_MinutesToDouble(){
- String testMinutesCoord = "-80:05.10000";
- String message;
- double result;
-
- result = Location.convert(testMinutesCoord);
- message = "minutesToDoubleTest: Double should be -80.085, actual value is " +
- String.valueOf(result);
- assertEquals(message, -80.085, result);
- }
-
- public void testConvert_SecondsToDouble(){
- String testSecondsCoord = "-80:04:03.00000";
- String message;
- double result;
-
- result = Location.convert(testSecondsCoord);
- message = "secondsToDoubleTest: Double should be -80.0675, actual value is " +
- String.valueOf(result);
- assertEquals(message, -80.0675, result);
- }
-
- public void testConvert_SecondsToDouble2(){
- String testSecondsCoord = "-80:4:3";
- String message;
- double result;
-
- result = Location.convert(testSecondsCoord);
- message = "secondsToDouble2Test: Double should be -80.0675, actual value is " +
- String.valueOf(result);
- assertEquals(message, -80.0675, result);
- }
-
- // Testing the Convert(Double, Int)
- public void testConvert_CoordinateToDegrees(){
- String message;
- String result;
-
- result = Location.convert(-80.075, Location.FORMAT_DEGREES);
- message = "coordinateToDegreesTest: Should return a string -80.075, but returned " + result;
- assertEquals(message, "-80.075", result);
- }
-
- public void testConvert_CoordinateToDegrees2(){
- String message;
- String result;
- result = Location.convert(-80.0, Location.FORMAT_DEGREES);
- message = "coordinateToDegrees2Test: Should return a string -80, but returned " + result;
- assertEquals(message, "-80", result);
- }
-
- public void testConvert_CoordinateToMinutes(){
- String message;
- String result;
- double input = -80.085;
- result = Location.convert(input, Location.FORMAT_MINUTES);
- message = "coordinateToMinuteTest: Should return a string -80:5.1, but returned " +
- result;
- assertEquals(message, "-80:5.1", result);
- }
-
- public void testConvert_CoordinateToMinutes2(){
- String message;
- String result;
- double input = -80;
- result = Location.convert(input, Location.FORMAT_MINUTES);
- message = "coordinateToMinute2Test: Should return a string -80:0, but returned " +
- result;
- assertEquals(message, "-80:0", result);
- }
-
- public void testConvert_CoordinateToSeconds(){
- String message;
- String result;
-
- result = Location.convert(-80.075, Location.FORMAT_SECONDS);
- message = "coordinateToSecondsTest: Should return a string -80:4:30, but returned " +
- result;
- assertEquals(message, "-80:4:30", result);
- }
- // **** end tests for Location.convert
-
-
- public void testBearingTo(){
- String message;
- float bearing;
- Location zeroLocation = new Location("");
- zeroLocation.setLatitude(0);
- zeroLocation.setLongitude(0);
-
- Location testLocation = new Location("");
- testLocation.setLatitude(1000000);
- testLocation.setLongitude(0);
-
- bearing = zeroLocation.bearingTo(zeroLocation);
- message = "bearingToTest: Bearing should be 0, actual value is " + String.valueOf(bearing);
- assertEquals(message, 0, bearing, 0);
-
- bearing = zeroLocation.bearingTo(testLocation);
- message = "bearingToTest: Bearing should be 180, actual value is " +
- String.valueOf(bearing);
- assertEquals(message, 180, bearing, 0);
-
- testLocation.setLatitude(0);
- testLocation.setLongitude(1000000);
- bearing = zeroLocation.bearingTo(testLocation);
- message = "bearingToTest: Bearing should be -90, actual value is " +
- String.valueOf(bearing);
- assertEquals(message, -90, bearing, 0);
-
- //TODO: Test a Random Middle Value
- }
-
- public void testDistanceTo() {
- String message;
- boolean result = true;
- float distance;
- Location zeroLocation = new Location("");
- zeroLocation.setLatitude(0);
- zeroLocation.setLongitude(0);
-
- Location testLocation = new Location("");
- testLocation.setLatitude(1000000);
- testLocation.setLongitude(0);
-
- distance = zeroLocation.distanceTo(zeroLocation);
- message = "distanceToTest: Distance should be 0, actual value is " +
- String.valueOf(distance);
- assertEquals(message, distance, 0, 0);
-
- distance = zeroLocation.distanceTo(testLocation);
- message = "distanceToTest: Distance should be 8885140, actual value is " +
- String.valueOf(distance);
- assertEquals(message, distance, 8885140.0, 1);
- }
-
- public void testAltitude() {
- String message;
- Location loc = new Location("");
-
- loc.setAltitude(1);
- message = "altitudeTest: set/getAltitude to 1 didn't work.";
- assertEquals(message, loc.getAltitude(), 1, 0);
- message = "altitudeTest: hasAltitude (a) didn't work.";
- assertTrue(message, loc.hasAltitude());
-
- loc.removeAltitude();
- message = "altitudeTest: hasAltitude (b) didn't work.";
- assertFalse(message, loc.hasAltitude());
- message = "altitudeTest: getAltitude didn't return 0 when there was no altitude.";
- assertEquals(message, loc.getAltitude(), 0, 0);
- }
-
- public void testSpeed() {
- String message;
- Location loc = new Location("");
-
- loc.setSpeed(1);
- message = "speedTest: set/getSpeed to 1 didn't work.";
- assertEquals(message, loc.getSpeed(), 1, 0);
- message = "speedTest: hasSpeed (a) didn't work.";
- assertTrue(message, loc.hasSpeed());
-
- loc.removeSpeed();
- message = "speedTest: hasSpeed (b) didn't work.";
- assertFalse(message, loc.hasSpeed());
- message = "speedTest: getSpeed didn't return 0 when there was no speed.";
- assertEquals(message, loc.getSpeed(), 0, 0);
- }
-
- public void testBearing() {
- String message;
- Location loc = new Location("");
-
- loc.setBearing(1);
- message = "bearingTest: set/getBearing to 1 didn't work.";
- assertEquals(message, loc.getBearing(), 1, 0);
- message = "bearingTest: hasBearing (a) didn't work.";
- assertTrue(message, loc.hasBearing());
-
- loc.removeBearing();
- message = "bearingTest: hasBearing (b) didn't work.";
- assertFalse(message, loc.hasBearing());
- message = "bearingTest: getBearing didn't return 0 when there was no bearing.";
- assertEquals(message, loc.getBearing(), 0, 0);
- }
-
-}
-
-
diff --git a/tests/CoreTests/android/util/DayOfMonthCursorTest.java b/tests/CoreTests/android/util/DayOfMonthCursorTest.java
deleted file mode 100644
index 4c5ad76..0000000
--- a/tests/CoreTests/android/util/DayOfMonthCursorTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.util;
-
-import junit.framework.TestCase;
-
-import java.util.Calendar;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Unit tests for {@link DayOfMonthCursor}.
- */
-public class DayOfMonthCursorTest extends TestCase {
-
- @SmallTest
- public void testMonthRows() {
- DayOfMonthCursor mc = new DayOfMonthCursor(2007,
- Calendar.SEPTEMBER, 11, Calendar.SUNDAY);
-
- assertArraysEqual(new int[]{26, 27, 28, 29, 30, 31, 1},
- mc.getDigitsForRow(0));
- assertArraysEqual(new int[]{2, 3, 4, 5, 6, 7, 8},
- mc.getDigitsForRow(1));
- assertArraysEqual(new int[]{30, 1, 2, 3, 4, 5, 6},
- mc.getDigitsForRow(5));
- }
-
- @SmallTest
- public void testMoveLeft() {
- DayOfMonthCursor mc = new DayOfMonthCursor(2007,
- Calendar.SEPTEMBER, 3, Calendar.SUNDAY);
-
- assertEquals(Calendar.SEPTEMBER, mc.getMonth());
- assertEquals(3, mc.getSelectedDayOfMonth());
- assertEquals(1, mc.getSelectedRow());
- assertEquals(1, mc.getSelectedColumn());
-
- // move left, still same row
- assertFalse(mc.left());
- assertEquals(2, mc.getSelectedDayOfMonth());
- assertEquals(1, mc.getSelectedRow());
- assertEquals(0, mc.getSelectedColumn());
-
- // wrap over to previous column, same month
- assertFalse(mc.left());
- assertEquals(1, mc.getSelectedDayOfMonth());
- assertEquals(0, mc.getSelectedRow());
- assertEquals(6, mc.getSelectedColumn());
-
- // wrap to previous month
- assertTrue(mc.left());
- assertEquals(Calendar.AUGUST, mc.getMonth());
- assertEquals(31, mc.getSelectedDayOfMonth());
- assertEquals(4, mc.getSelectedRow());
- assertEquals(5, mc.getSelectedColumn());
- }
-
- @SmallTest
- public void testMoveRight() {
- DayOfMonthCursor mc = new DayOfMonthCursor(2007,
- Calendar.SEPTEMBER, 28, Calendar.SUNDAY);
-
- assertEquals(Calendar.SEPTEMBER, mc.getMonth());
- assertEquals(28, mc.getSelectedDayOfMonth());
- assertEquals(4, mc.getSelectedRow());
- assertEquals(5, mc.getSelectedColumn());
-
- // same row
- assertFalse(mc.right());
- assertEquals(29, mc.getSelectedDayOfMonth());
- assertEquals(4, mc.getSelectedRow());
- assertEquals(6, mc.getSelectedColumn());
-
- // wrap to next column, same month
- assertFalse(mc.right());
- assertEquals(30, mc.getSelectedDayOfMonth());
- assertEquals(5, mc.getSelectedRow());
- assertEquals(0, mc.getSelectedColumn());
-
- // next month
- assertTrue(mc.right());
- assertEquals(Calendar.OCTOBER, mc.getMonth());
- assertEquals(1, mc.getSelectedDayOfMonth());
- assertEquals(0, mc.getSelectedRow());
- assertEquals(1, mc.getSelectedColumn());
- }
-
- @SmallTest
- public void testMoveUp() {
- DayOfMonthCursor mc = new DayOfMonthCursor(2007,
- Calendar.SEPTEMBER, 13, Calendar.SUNDAY);
-
- assertEquals(Calendar.SEPTEMBER, mc.getMonth());
- assertEquals(13, mc.getSelectedDayOfMonth());
- assertEquals(2, mc.getSelectedRow());
- assertEquals(4, mc.getSelectedColumn());
-
- // up, same month
- assertFalse(mc.up());
- assertEquals(6, mc.getSelectedDayOfMonth());
- assertEquals(1, mc.getSelectedRow());
- assertEquals(4, mc.getSelectedColumn());
-
- // up, flips back
- assertTrue(mc.up());
- assertEquals(Calendar.AUGUST, mc.getMonth());
- assertEquals(30, mc.getSelectedDayOfMonth());
- assertEquals(4, mc.getSelectedRow());
- assertEquals(4, mc.getSelectedColumn());
- }
-
- @SmallTest
- public void testMoveDown() {
- DayOfMonthCursor mc = new DayOfMonthCursor(2007,
- Calendar.SEPTEMBER, 23, Calendar.SUNDAY);
-
- assertEquals(Calendar.SEPTEMBER, mc.getMonth());
- assertEquals(23, mc.getSelectedDayOfMonth());
- assertEquals(4, mc.getSelectedRow());
- assertEquals(0, mc.getSelectedColumn());
-
- // down, same month
- assertFalse(mc.down());
- assertEquals(30, mc.getSelectedDayOfMonth());
- assertEquals(5, mc.getSelectedRow());
- assertEquals(0, mc.getSelectedColumn());
-
- // down, next month
- assertTrue(mc.down());
- assertEquals(Calendar.OCTOBER, mc.getMonth());
- assertEquals(7, mc.getSelectedDayOfMonth());
- assertEquals(1, mc.getSelectedRow());
- assertEquals(0, mc.getSelectedColumn());
- }
-
- private void assertArraysEqual(int[] expected, int[] actual) {
- assertEquals("array length", expected.length, actual.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("index " + i,
- expected[i], actual[i]);
- }
- }
-}
diff --git a/tests/CoreTests/android/util/FloatMathTest.java b/tests/CoreTests/android/util/FloatMathTest.java
deleted file mode 100644
index f479e2b..0000000
--- a/tests/CoreTests/android/util/FloatMathTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.util;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class FloatMathTest extends TestCase {
-
- @SmallTest
- public void testSqrt() {
- assertEquals(7, FloatMath.sqrt(49), 0);
- assertEquals(10, FloatMath.sqrt(100), 0);
- assertEquals(0, FloatMath.sqrt(0), 0);
- assertEquals(1, FloatMath.sqrt(1), 0);
- }
-
- @SmallTest
- public void testFloor() {
- assertEquals(78, FloatMath.floor(78.89f), 0);
- assertEquals(-79, FloatMath.floor(-78.89f), 0);
- }
-
- @SmallTest
- public void testCeil() {
- assertEquals(79, FloatMath.ceil(78.89f), 0);
- assertEquals(-78, FloatMath.ceil(-78.89f), 0);
- }
-
- @SmallTest
- public void testSin() {
- assertEquals(0.0, FloatMath.sin(0), 0);
- assertEquals(0.8414709848078965f, FloatMath.sin(1), 0);
- }
-
- @SmallTest
- public void testCos() {
- assertEquals(1.0f, FloatMath.cos(0), 0);
- assertEquals(0.5403023058681398f, FloatMath.cos(1), 0);
- }
-}
diff --git a/tests/CoreTests/android/util/MonthDisplayHelperTest.java b/tests/CoreTests/android/util/MonthDisplayHelperTest.java
deleted file mode 100644
index 5207ad9..0000000
--- a/tests/CoreTests/android/util/MonthDisplayHelperTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.util;
-
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.util.Calendar;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Unit tests for {@link MonthDisplayHelper}.
- */
-public class MonthDisplayHelperTest extends TestCase {
-
-
- @SmallTest
- public void testFirstDayOfMonth() {
-
- assertEquals("august 2007",
- Calendar.WEDNESDAY,
- new MonthDisplayHelper(2007, Calendar.AUGUST).getFirstDayOfMonth());
-
- assertEquals("september, 2007",
- Calendar.SATURDAY,
- new MonthDisplayHelper(2007, Calendar.SEPTEMBER).getFirstDayOfMonth());
- }
-
- @MediumTest
- public void testNumberOfDaysInCurrentMonth() {
- assertEquals(30,
- new MonthDisplayHelper(2007, Calendar.SEPTEMBER).getNumberOfDaysInMonth());
- }
-
- @SmallTest
- public void testMonthRows() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007, Calendar.SEPTEMBER);
-
- assertArraysEqual(new int[]{26, 27, 28, 29, 30, 31, 1},
- helper.getDigitsForRow(0));
- assertArraysEqual(new int[]{2, 3, 4, 5, 6, 7, 8},
- helper.getDigitsForRow(1));
- assertArraysEqual(new int[]{30, 1, 2, 3, 4, 5, 6},
- helper.getDigitsForRow(5));
-
- }
-
- @SmallTest
- public void testMonthRowsWeekStartsMonday() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.SEPTEMBER, Calendar.MONDAY);
-
- assertArraysEqual(new int[]{27, 28, 29, 30, 31, 1, 2},
- helper.getDigitsForRow(0));
- assertArraysEqual(new int[]{3, 4, 5, 6, 7, 8, 9},
- helper.getDigitsForRow(1));
- assertArraysEqual(new int[]{24, 25, 26, 27, 28, 29, 30},
- helper.getDigitsForRow(4));
- assertArraysEqual(new int[]{1, 2, 3, 4, 5, 6, 7},
- helper.getDigitsForRow(5));
- }
-
- @SmallTest
- public void testMonthRowsWeekStartsSaturday() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.SEPTEMBER, Calendar.SATURDAY);
-
- assertArraysEqual(new int[]{1, 2, 3, 4, 5, 6, 7},
- helper.getDigitsForRow(0));
- assertArraysEqual(new int[]{8, 9, 10, 11, 12, 13, 14},
- helper.getDigitsForRow(1));
- assertArraysEqual(new int[]{29, 30, 1, 2, 3, 4, 5},
- helper.getDigitsForRow(4));
-
-
- helper = new MonthDisplayHelper(2007,
- Calendar.AUGUST, Calendar.SATURDAY);
-
- assertArraysEqual(new int[]{28, 29, 30, 31, 1, 2, 3},
- helper.getDigitsForRow(0));
- assertArraysEqual(new int[]{4, 5, 6, 7, 8, 9, 10},
- helper.getDigitsForRow(1));
- assertArraysEqual(new int[]{25, 26, 27, 28, 29, 30, 31},
- helper.getDigitsForRow(4));
- }
-
- @SmallTest
- public void testGetDayAt() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.SEPTEMBER, Calendar.SUNDAY);
-
- assertEquals(26, helper.getDayAt(0, 0));
- assertEquals(1, helper.getDayAt(0, 6));
- assertEquals(17, helper.getDayAt(3, 1));
- assertEquals(2, helper.getDayAt(5, 2));
- }
-
- @SmallTest
- public void testPrevMonth() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.SEPTEMBER, Calendar.SUNDAY);
-
- assertArraysEqual(new int[]{26, 27, 28, 29, 30, 31, 1},
- helper.getDigitsForRow(0));
-
- helper.previousMonth();
-
- assertEquals(Calendar.AUGUST, helper.getMonth());
- assertArraysEqual(new int[]{29, 30, 31, 1, 2, 3, 4},
- helper.getDigitsForRow(0));
- }
-
- @SmallTest
- public void testPrevMonthRollOver() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.JANUARY);
-
- helper.previousMonth();
-
- assertEquals(2006, helper.getYear());
- assertEquals(Calendar.DECEMBER, helper.getMonth());
- }
-
- @SmallTest
- public void testNextMonth() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.AUGUST, Calendar.SUNDAY);
-
- assertArraysEqual(new int[]{29, 30, 31, 1, 2, 3, 4},
- helper.getDigitsForRow(0));
-
- helper.nextMonth();
-
- assertEquals(Calendar.SEPTEMBER, helper.getMonth());
- assertArraysEqual(new int[]{26, 27, 28, 29, 30, 31, 1},
- helper.getDigitsForRow(0));
- }
-
- @SmallTest
- public void testGetRowOf() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.AUGUST, Calendar.SUNDAY);
-
- assertEquals(0, helper.getRowOf(2));
- assertEquals(0, helper.getRowOf(4));
- assertEquals(2, helper.getRowOf(12));
- assertEquals(2, helper.getRowOf(18));
- assertEquals(3, helper.getRowOf(19));
- }
-
- @SmallTest
- public void testGetColumnOf() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.AUGUST, Calendar.SUNDAY);
-
- assertEquals(3, helper.getColumnOf(1));
- assertEquals(4, helper.getColumnOf(9));
- assertEquals(5, helper.getColumnOf(17));
- assertEquals(6, helper.getColumnOf(25));
- assertEquals(0, helper.getColumnOf(26));
- }
-
- @SmallTest
- public void testWithinCurrentMonth() {
- MonthDisplayHelper helper = new MonthDisplayHelper(2007,
- Calendar.SEPTEMBER, Calendar.SUNDAY);
-
- // out of bounds
- assertFalse(helper.isWithinCurrentMonth(-1, 3));
- assertFalse(helper.isWithinCurrentMonth(6, 3));
- assertFalse(helper.isWithinCurrentMonth(2, -1));
- assertFalse(helper.isWithinCurrentMonth(2, 7));
-
- // last day of previous month
- assertFalse(helper.isWithinCurrentMonth(0, 5));
-
- // first day of next month
- assertFalse(helper.isWithinCurrentMonth(5, 1));
-
- // first day in month
- assertTrue(helper.isWithinCurrentMonth(0, 6));
-
- // last day in month
- assertTrue(helper.isWithinCurrentMonth(5, 0));
- }
-
- private void assertArraysEqual(int[] expected, int[] actual) {
- assertEquals("array length", expected.length, actual.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("index " + i,
- expected[i], actual[i]);
- }
- }
-
-}
diff --git a/tests/CoreTests/android/util/StateSetTest.java b/tests/CoreTests/android/util/StateSetTest.java
deleted file mode 100644
index e481ce04..0000000
--- a/tests/CoreTests/android/util/StateSetTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.util;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests for {@link StateSet}
- */
-
-public class StateSetTest extends TestCase {
-
- @SmallTest
- public void testStateSetPositiveMatches() throws Exception {
- int[] stateSpec = new int[2];
- int[] stateSet = new int[3];
- // Single states in both sets - match
- stateSpec[0] = 1;
- stateSet[0] = 1;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- // Single states in both sets - non-match
- stateSet[0] = 2;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add another state to the spec which the stateSet doesn't match
- stateSpec[1] = 2;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add the missing matching element to the stateSet
- stateSet[1] = 1;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add an irrelevent state to the stateSpec
- stateSet[2] = 12345;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- }
-
- @SmallTest
- public void testStatesSetMatchMixEmUp() throws Exception {
- int[] stateSpec = new int[2];
- int[] stateSet = new int[2];
- // One element in stateSpec which we must match and one which we must
- // not match. stateSet only contains the match.
- stateSpec[0] = 1;
- stateSpec[1] = -2;
- stateSet[0] = 1;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- // stateSet now contains just the element we must not match
- stateSet[0] = 2;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add another matching state to the the stateSet. We still fail
- // because stateSet contains a must-not-match element
- stateSet[1] = 1;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Switch the must-not-match element in stateSet with a don't care
- stateSet[0] = 12345;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- }
-
- @SmallTest
- public void testStateSetNegativeMatches() throws Exception {
- int[] stateSpec = new int[2];
- int[] stateSet = new int[3];
- // Single states in both sets - match
- stateSpec[0] = -1;
- stateSet[0] = 2;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add another arrelevent state to the stateSet
- stateSet[1] = 12345;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- // Single states in both sets - non-match
- stateSet[0] = 1;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add another state to the spec which the stateSet doesn't match
- stateSpec[1] = -2;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // Add an irrelevent state to the stateSet
- stateSet[2] = 12345;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- }
-
- @SmallTest
- public void testEmptySetMatchesNegtives() throws Exception {
- int[] stateSpec = {-12345, -6789};
- int[] stateSet = new int[0];
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- int[] stateSet2 = {0};
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet2));
- }
-
- @SmallTest
- public void testEmptySetFailsPositives() throws Exception {
- int[] stateSpec = {12345};
- int[] stateSet = new int[0];
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- int[] stateSet2 = {0};
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet2));
- }
-
- @SmallTest
- public void testEmptySetMatchesWildcard() throws Exception {
- int[] stateSpec = StateSet.WILD_CARD;
- int[] stateSet = new int[0];
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- int[] stateSet2 = {0};
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet2));
- }
-
- @SmallTest
- public void testSingleStatePositiveMatches() throws Exception {
- int[] stateSpec = new int[2];
- int state;
- // match
- stateSpec[0] = 1;
- state = 1;
- assertTrue(StateSet.stateSetMatches(stateSpec, state));
- // non-match
- state = 2;
- assertFalse(StateSet.stateSetMatches(stateSpec, state));
- // add irrelevant must-not-match
- stateSpec[1] = -12345;
- assertFalse(StateSet.stateSetMatches(stateSpec, state));
- }
-
- @SmallTest
- public void testSingleStateNegativeMatches() throws Exception {
- int[] stateSpec = new int[2];
- int state;
- // match
- stateSpec[0] = -1;
- state = 1;
- assertFalse(StateSet.stateSetMatches(stateSpec, state));
- // non-match
- state = 2;
- assertTrue(StateSet.stateSetMatches(stateSpec, state));
- // add irrelevant must-not-match
- stateSpec[1] = -12345;
- assertTrue(StateSet.stateSetMatches(stateSpec, state));
- }
-
- @SmallTest
- public void testZeroStateOnlyMatchesDefault() throws Exception {
- int[] stateSpec = new int[3];
- int state = 0;
- // non-match
- stateSpec[0] = 1;
- assertFalse(StateSet.stateSetMatches(stateSpec, state));
- // non-match
- stateSpec[1] = -1;
- assertFalse(StateSet.stateSetMatches(stateSpec, state));
- // match
- stateSpec = StateSet.WILD_CARD;
- assertTrue(StateSet.stateSetMatches(stateSpec, state));
- }
-
- @SmallTest
- public void testNullStateOnlyMatchesDefault() throws Exception {
- int[] stateSpec = new int[3];
- int[] stateSet = null;
- // non-match
- stateSpec[0] = 1;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // non-match
- stateSpec[1] = -1;
- assertFalse(StateSet.stateSetMatches(stateSpec, stateSet));
- // match
- stateSpec = StateSet.WILD_CARD;
- assertTrue(StateSet.stateSetMatches(stateSpec, stateSet));
- }
-}
diff --git a/tests/CoreTests/android/view/FocusFinderTest.java b/tests/CoreTests/android/view/FocusFinderTest.java
deleted file mode 100644
index 7ac8dfc..0000000
--- a/tests/CoreTests/android/view/FocusFinderTest.java
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.view;
-
-import android.graphics.Rect;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class FocusFinderTest extends AndroidTestCase {
-
- private FocusFinderHelper mFocusFinder;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mFocusFinder = new FocusFinderHelper(FocusFinder.getInstance());
- }
-
- @SmallTest
- public void testPreconditions() {
- assertNotNull("focus finder instance", mFocusFinder);
- }
-
- @SmallTest
- public void testBelowNotCandidateForDirectionUp() {
- assertIsNotCandidate(View.FOCUS_UP,
- new Rect(0, 30, 10, 40), // src (left, top, right, bottom)
- new Rect(0, 50, 10, 60)); // dest (left, top, right, bottom)
- }
-
- @SmallTest
- public void testAboveShareEdgeEdgeOkForDirectionUp() {
- final Rect src = new Rect(0, 30, 10, 40);
-
- final Rect dest = new Rect(src);
- dest.offset(0, -src.height());
- assertEquals(src.top, dest.bottom);
-
- assertDirectionIsCandidate(View.FOCUS_UP, src, dest);
- }
-
- @SmallTest
- public void testCompletelyContainedNotCandidate() {
- assertIsNotCandidate(
- View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50),
- new Rect(0, 1, 50, 49));
- }
-
- @SmallTest
- public void testContinaedWithCommonBottomNotCandidate() {
- assertIsNotCandidate(
- View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50),
- new Rect(0, 1, 50, 50));
- }
-
- @SmallTest
- public void testOverlappingIsCandidateWhenBothEdgesAreInDirection() {
- assertDirectionIsCandidate(
- View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50),
- new Rect(0, 1, 50, 51));
- }
-
- @SmallTest
- public void testTopEdgeOfDestAtOrAboveTopOfSrcNotCandidateForDown() {
- assertIsNotCandidate(
- View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50),
- new Rect(0, 0, 50, 51));
- assertIsNotCandidate(
- View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50),
- new Rect(0, -1, 50, 51));
- }
-
- @SmallTest
- public void testSameRectBeamsOverlap() {
- final Rect rect = new Rect(0, 0, 20, 20);
-
- assertBeamsOverlap(View.FOCUS_LEFT, rect, rect);
- assertBeamsOverlap(View.FOCUS_RIGHT, rect, rect);
- assertBeamsOverlap(View.FOCUS_UP, rect, rect);
- assertBeamsOverlap(View.FOCUS_DOWN, rect, rect);
- }
-
- @SmallTest
- public void testOverlapBeamsRightLeftUpToEdge() {
- final Rect rect1 = new Rect(0, 0, 20, 20);
- final Rect rect2 = new Rect(rect1);
-
- // just below bottom edge
- rect2.offset(0, rect1.height() - 1);
- assertBeamsOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_RIGHT, rect1, rect2);
-
- // at edge
- rect2.offset(0, 1);
- assertBeamsOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_RIGHT, rect1, rect2);
-
- // just beyond
- rect2.offset(0, 1);
- assertBeamsDontOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsDontOverlap(View.FOCUS_RIGHT, rect1, rect2);
-
- // just below top edge
- rect2.set(rect1);
- rect2.offset(0, -(rect1.height() - 1));
- assertBeamsOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_RIGHT, rect1, rect2);
-
- // at top edge
- rect2.offset(0, -1);
- assertBeamsOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_RIGHT, rect1, rect2);
-
- // just beyond top edge
- rect2.offset(0, -1);
- assertBeamsDontOverlap(View.FOCUS_LEFT, rect1, rect2);
- assertBeamsDontOverlap(View.FOCUS_RIGHT, rect1, rect2);
- }
-
- @SmallTest
- public void testOverlapBeamsUpDownUpToEdge() {
- final Rect rect1 = new Rect(0, 0, 20, 20);
- final Rect rect2 = new Rect(rect1);
-
- // just short of right edge
- rect2.offset(rect1.width() - 1, 0);
- assertBeamsOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_DOWN, rect1, rect2);
-
- // at edge
- rect2.offset(1, 0);
- assertBeamsOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_DOWN, rect1, rect2);
-
- // just beyond
- rect2.offset(1, 0);
- assertBeamsDontOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsDontOverlap(View.FOCUS_DOWN, rect1, rect2);
-
- // just short of left edge
- rect2.set(rect1);
- rect2.offset(-(rect1.width() - 1), 0);
- assertBeamsOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_DOWN, rect1, rect2);
-
- // at edge
- rect2.offset(-1, 0);
- assertBeamsOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsOverlap(View.FOCUS_DOWN, rect1, rect2);
-
- // just beyond edge
- rect2.offset(-1, 0);
- assertBeamsDontOverlap(View.FOCUS_UP, rect1, rect2);
- assertBeamsDontOverlap(View.FOCUS_DOWN, rect1, rect2);
- }
-
- @SmallTest
- public void testDirectlyAboveTrumpsAboveLeft() {
- Rect src = new Rect(0, 50, 20, 70); // src (left, top, right, bottom)
-
- Rect directlyAbove = new Rect(src);
- directlyAbove.offset(0, -(1 + src.height()));
-
- Rect aboveLeft = new Rect(src);
- aboveLeft.offset(-(1 + src.width()), -(1 + src.height()));
-
- assertBetterCandidate(View.FOCUS_UP, src, directlyAbove, aboveLeft);
- }
-
- @SmallTest
- public void testAboveInBeamTrumpsSlightlyCloserOutOfBeam() {
- Rect src = new Rect(0, 50, 20, 70); // src (left, top, right, bottom)
-
- Rect directlyAbove = new Rect(src);
- directlyAbove.offset(0, -(1 + src.height()));
-
- Rect aboveLeft = new Rect(src);
- aboveLeft.offset(-(1 + src.width()), -(1 + src.height()));
-
- // offset directly above a little further up
- directlyAbove.offset(0, -5);
- assertBetterCandidate(View.FOCUS_UP, src, directlyAbove, aboveLeft);
- }
-
- @SmallTest
- public void testOutOfBeamBeatsInBeamUp() {
-
- Rect src = new Rect(0, 0, 50, 50); // (left, top, right, bottom)
-
- Rect aboveLeftOfBeam = new Rect(src);
- aboveLeftOfBeam.offset(-(src.width() + 1), -src.height());
- assertBeamsDontOverlap(View.FOCUS_UP, src, aboveLeftOfBeam);
-
- Rect aboveInBeam = new Rect(src);
- aboveInBeam.offset(0, -src.height());
- assertBeamsOverlap(View.FOCUS_UP, src, aboveInBeam);
-
- // in beam wins
- assertBetterCandidate(View.FOCUS_UP, src, aboveInBeam, aboveLeftOfBeam);
-
- // still wins while aboveInBeam's bottom edge is < out of beams' top
- aboveInBeam.offset(0, -(aboveLeftOfBeam.height() - 1));
- assertTrue("aboveInBeam.bottom > aboveLeftOfBeam.top", aboveInBeam.bottom > aboveLeftOfBeam.top);
- assertBetterCandidate(View.FOCUS_UP, src, aboveInBeam, aboveLeftOfBeam);
-
- // cross the threshold: the out of beam prevails
- aboveInBeam.offset(0, -1);
- assertEquals(aboveInBeam.bottom, aboveLeftOfBeam.top);
- assertBetterCandidate(View.FOCUS_UP, src, aboveLeftOfBeam, aboveInBeam);
- }
-
- /**
- * A non-candidate (even a much closer one) is always a worse choice
- * than a real candidate.
- */
- @MediumTest
- public void testSomeCandidateBetterThanNonCandidate() {
- Rect src = new Rect(0, 0, 50, 50); // (left, top, right, bottom)
-
- Rect nonCandidate = new Rect(src);
- nonCandidate.offset(src.width() + 1, 0);
-
- assertIsNotCandidate(View.FOCUS_LEFT, src, nonCandidate);
-
- Rect candidate = new Rect(src);
- candidate.offset(-(4 * src.width()), 0);
- assertDirectionIsCandidate(View.FOCUS_LEFT, src, candidate);
-
- assertBetterCandidate(View.FOCUS_LEFT, src, candidate, nonCandidate);
- }
-
- /**
- * Grabbed from {@link com.android.frameworktest.focus.VerticalFocusSearchTest#testSearchFromMidLeft()}
- */
- @SmallTest
- public void testVerticalFocusSearchScenario() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 109, 153, 169), // src
- new Rect(166, 169, 319, 229), // expectedbetter
- new Rect(0, 229, 320, 289)); // expectedworse
-
- // failing test 4/10/2008, the values were tweaked somehow in functional
- // test...
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 91, 153, 133), // src
- new Rect(166, 133, 319, 175), // expectedbetter
- new Rect(0, 175, 320, 217)); // expectedworse
-
- }
-
- /**
- * Example: going down from a thin button all the way to the left of a
- * screen where, just below, is a very wide button, and just below that,
- * is an equally skinny button all the way to the left. want to make
- * sure any minor axis factor doesn't override the fact that the one below
- * in vertical beam should be next focus
- */
- @SmallTest
- public void testBeamsOverlapMajorAxisCloserMinorAxisFurther() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 100, 100), // src
- new Rect(0, 100, 480, 200), // expectedbetter
- new Rect(0, 200, 100, 300)); // expectedworse
- }
-
- /**
- * Real scenario grabbed from song playback screen.
- */
- @SmallTest
- public void testMusicPlaybackScenario() {
- assertBetterCandidate(View.FOCUS_LEFT,
- // L T R B
- new Rect(227, 185, 312, 231), // src
- new Rect(195, 386, 266, 438), // expectedbetter
- new Rect(124, 386, 195, 438)); // expectedworse
- }
-
- /**
- * more generalized version of {@link #testMusicPlaybackScenario()}
- */
- @SmallTest
- public void testOutOfBeamOverlapBeatsOutOfBeamFurtherOnMajorAxis() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50), // src
- new Rect(60, 40, 110, 90), // expectedbetter
- new Rect(60, 70, 110, 120)); // expectedworse
- }
-
- /**
- * Make sure that going down prefers views that are actually
- * down (and not those next to but still a candidate because
- * they are overlapping on the major axis)
- */
- @SmallTest
- public void testInBeamTrumpsOutOfBeamOverlapping() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50), // src
- new Rect(0, 60, 50, 110), // expectedbetter
- new Rect(51, 1, 101, 51)); // expectedworse
- }
-
- @SmallTest
- public void testOverlappingBeatsNonOverlapping() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 50, 50), // src
- new Rect(0, 40, 50, 90), // expectedbetter
- new Rect(0, 75, 50, 125)); // expectedworse
- }
-
- @SmallTest
- public void testEditContactScenarioLeftFromDiscardChangesGoesToSaveContactInLandscape() {
- assertBetterCandidate(View.FOCUS_LEFT,
- // L T R B
- new Rect(357, 258, 478, 318), // src
- new Rect(2, 258, 100, 318), // better
- new Rect(106, 120, 424, 184)); // worse
- }
-
- /**
- * A dial pad with 9 squares arranged in a grid. no padding, so
- * the edges are equal. see {@link com.android.frameworktest.focus.LinearLayoutGrid}
- */
- @SmallTest
- public void testGridWithTouchingEdges() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(106, 49, 212, 192), // src
- new Rect(106, 192, 212, 335), // better
- new Rect(0, 192, 106, 335)); // worse
-
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(106, 49, 212, 192), // src
- new Rect(106, 192, 212, 335), // better
- new Rect(212, 192, 318, 335)); // worse
- }
-
- @SmallTest
- public void testSearchFromEmptyRect() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 0, 0), // src
- new Rect(0, 0, 320, 45), // better
- new Rect(0, 45, 320, 545)); // worse
- }
-
- /**
- * Reproduce bug 1124559, drilling down to actual bug
- * (majorAxisDistance was wrong for direction left)
- */
- @SmallTest
- public void testGmailReplyButtonsScenario() {
- assertBetterCandidate(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417), // src
- new Rect(102, 380, 210, 417), // better
- new Rect(111, 443, 206, 480)); // worse
-
- assertBeamBeats(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417), // src
- new Rect(102, 380, 210, 417), // better
- new Rect(111, 443, 206, 480)); // worse
-
- assertBeamsOverlap(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417),
- new Rect(102, 380, 210, 417));
-
- assertBeamsDontOverlap(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417),
- new Rect(111, 443, 206, 480));
-
- assertTrue(
- "major axis distance less than major axis distance to "
- + "far edge",
- FocusFinderHelper.majorAxisDistance(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417),
- new Rect(102, 380, 210, 417)) <
- FocusFinderHelper.majorAxisDistanceToFarEdge(View.FOCUS_LEFT,
- // L T R B
- new Rect(223, 380, 312, 417),
- new Rect(111, 443, 206, 480)));
- }
-
- @SmallTest
- public void testGmailScenarioBug1203288() {
- assertBetterCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 2, 480, 82), // src
- new Rect(344, 87, 475, 124), // better
- new Rect(0, 130, 480, 203)); // worse
- }
-
- @SmallTest
- public void testHomeShortcutScenarioBug1295354() {
- assertBetterCandidate(View.FOCUS_RIGHT,
- // L T R B
- new Rect(3, 338, 77, 413), // src
- new Rect(163, 338, 237, 413), // better
- new Rect(83, 38, 157, 113)); // worse
- }
-
- @SmallTest
- public void testBeamAlwaysBeatsHoriz() {
- assertBetterCandidate(View.FOCUS_RIGHT,
- // L T R B
- new Rect(0, 0, 50, 50), // src
- new Rect(150, 0, 200, 50), // better, (way further, but in beam)
- new Rect(60, 51, 110, 101)); // worse, even though it is closer
-
- assertBetterCandidate(View.FOCUS_LEFT,
- // L T R B
- new Rect(150, 0, 200, 50), // src
- new Rect(0, 50, 50, 50), // better, (way further, but in beam)
- new Rect(49, 99, 149, 101)); // worse, even though it is closer
- }
-
- @SmallTest
- public void testIsCandidateOverlappingEdgeFromEmptyRect() {
- assertDirectionIsCandidate(View.FOCUS_DOWN,
- // L T R B
- new Rect(0, 0, 0, 0), // src
- new Rect(0, 0, 20, 1)); // candidate
-
- assertDirectionIsCandidate(View.FOCUS_UP,
- // L T R B
- new Rect(0, 0, 0, 0), // src
- new Rect(0, -1, 20, 0)); // candidate
-
- assertDirectionIsCandidate(View.FOCUS_LEFT,
- // L T R B
- new Rect(0, 0, 0, 0), // src
- new Rect(-1, 0, 0, 20)); // candidate
-
- assertDirectionIsCandidate(View.FOCUS_RIGHT,
- // L T R B
- new Rect(0, 0, 0, 0), // src
- new Rect(0, 0, 1, 20)); // candidate
- }
-
- private void assertBeamsOverlap(int direction, Rect rect1, Rect rect2) {
- String directionStr = validateAndGetStringFor(direction);
- String assertMsg = String.format("Expected beams to overlap in direction %s "
- + "for rectangles %s and %s", directionStr, rect1, rect2);
- assertTrue(assertMsg, mFocusFinder.beamsOverlap(direction, rect1, rect2));
- }
-
- private void assertBeamsDontOverlap(int direction, Rect rect1, Rect rect2) {
- String directionStr = validateAndGetStringFor(direction);
- String assertMsg = String.format("Expected beams not to overlap in direction %s "
- + "for rectangles %s and %s", directionStr, rect1, rect2);
- assertFalse(assertMsg, mFocusFinder.beamsOverlap(direction, rect1, rect2));
- }
-
- /**
- * Assert that particular rect is a better focus search candidate from a
- * source rect than another.
- * @param direction The direction of focus search.
- * @param srcRect The src rectangle.
- * @param expectedBetter The candidate that should be better.
- * @param expectedWorse The candidate that should be worse.
- */
- private void assertBetterCandidate(int direction, Rect srcRect,
- Rect expectedBetter, Rect expectedWorse) {
-
- String directionStr = validateAndGetStringFor(direction);
- String assertMsg = String.format(
- "expected %s to be a better focus search candidate than "
- + "%s when searching "
- + "from %s in direction %s",
- expectedBetter, expectedWorse, srcRect, directionStr);
-
- assertTrue(assertMsg,
- mFocusFinder.isBetterCandidate(direction, srcRect,
- expectedBetter, expectedWorse));
-
- assertMsg = String.format(
- "expected %s to not be a better focus search candidate than "
- + "%s when searching "
- + "from %s in direction %s",
- expectedWorse, expectedBetter, srcRect, directionStr);
-
- assertFalse(assertMsg,
- mFocusFinder.isBetterCandidate(direction, srcRect,
- expectedWorse, expectedBetter));
- }
-
- private void assertIsNotCandidate(int direction, Rect src, Rect dest) {
- String directionStr = validateAndGetStringFor(direction);
-
- final String assertMsg = String.format(
- "expected going from %s to %s in direction %s to be an invalid "
- + "focus search candidate",
- src, dest, directionStr);
- assertFalse(assertMsg, mFocusFinder.isCandidate(src, dest, direction));
- }
-
- private void assertBeamBeats(int direction, Rect srcRect,
- Rect rect1, Rect rect2) {
-
- String directionStr = validateAndGetStringFor(direction);
- String assertMsg = String.format(
- "expecting %s to beam beat %s w.r.t %s in direction %s",
- rect1, rect2, srcRect, directionStr);
- assertTrue(assertMsg, mFocusFinder.beamBeats(direction, srcRect, rect1, rect2));
- }
-
-
- private void assertDirectionIsCandidate(int direction, Rect src, Rect dest) {
- String directionStr = validateAndGetStringFor(direction);
-
- final String assertMsg = String.format(
- "expected going from %s to %s in direction %s to be a valid "
- + "focus search candidate",
- src, dest, directionStr);
- assertTrue(assertMsg, mFocusFinder.isCandidate(src, dest, direction));
- }
-
- private String validateAndGetStringFor(int direction) {
- String directionStr = "??";
- switch(direction) {
- case View.FOCUS_UP:
- directionStr = "FOCUS_UP";
- break;
- case View.FOCUS_DOWN:
- directionStr = "FOCUS_DOWN";
- break;
- case View.FOCUS_LEFT:
- directionStr = "FOCUS_LEFT";
- break;
- case View.FOCUS_RIGHT:
- directionStr = "FOCUS_RIGHT";
- break;
- default:
- fail("passed in unknown direction, ya blewit!");
- }
- return directionStr;
- }
-
-
-}
diff --git a/tests/CoreTests/android/view/ViewGroupAttributesTest.java b/tests/CoreTests/android/view/ViewGroupAttributesTest.java
deleted file mode 100644
index b4ef0e7..0000000
--- a/tests/CoreTests/android/view/ViewGroupAttributesTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 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 android.view;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class ViewGroupAttributesTest extends AndroidTestCase {
-
- private MyViewGroup mViewGroup;
-
- private static final class MyViewGroup extends ViewGroup {
-
- public MyViewGroup(Context context) {
- super(context);
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- }
-
- @Override
- public boolean isChildrenDrawnWithCacheEnabled() {
- return super.isChildrenDrawnWithCacheEnabled();
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mViewGroup = new MyViewGroup(getContext());
- }
-
- @SmallTest
- public void testDescendantFocusabilityEnum() {
- assertEquals("expected ViewGroup.FOCUS_BEFORE_DESCENDANTS to be default",
- ViewGroup.FOCUS_BEFORE_DESCENDANTS, mViewGroup.getDescendantFocusability());
-
- // remember some state before we muck with flags
- final boolean isAnimationCachEnabled = mViewGroup.isAnimationCacheEnabled();
- final boolean isAlwaysDrawnWithCacheEnabled = mViewGroup.isAlwaysDrawnWithCacheEnabled();
- final boolean isChildrenDrawnWithCacheEnabled = mViewGroup.isChildrenDrawnWithCacheEnabled();
-
- mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
- assertEquals(ViewGroup.FOCUS_AFTER_DESCENDANTS, mViewGroup.getDescendantFocusability());
-
- mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
- assertEquals(ViewGroup.FOCUS_BLOCK_DESCENDANTS, mViewGroup.getDescendantFocusability());
-
- mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
- assertEquals(ViewGroup.FOCUS_BEFORE_DESCENDANTS, mViewGroup.getDescendantFocusability());
-
- // verify we didn't change something unrelated
- final String msg = "setDescendantFocusability messed with an unrelated flag";
- assertEquals(msg, isAnimationCachEnabled, mViewGroup.isAnimationCacheEnabled());
- assertEquals(msg, isAlwaysDrawnWithCacheEnabled, mViewGroup.isAlwaysDrawnWithCacheEnabled());
- assertEquals(msg, isChildrenDrawnWithCacheEnabled, mViewGroup.isChildrenDrawnWithCacheEnabled());
- }
-
- @SmallTest
- public void testWrongIntSetForDescendantFocusabilityEnum() {
- try {
- mViewGroup.setDescendantFocusability(0);
- fail("expected setting wrong flag to throw an exception");
- } catch (IllegalArgumentException expected) {
- }
- }
-}
diff --git a/tests/CoreTests/android/webkit/UrlInterceptRegistryTest.java b/tests/CoreTests/android/webkit/UrlInterceptRegistryTest.java
deleted file mode 100644
index 7504449..0000000
--- a/tests/CoreTests/android/webkit/UrlInterceptRegistryTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2009 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 android.webkit;
-
-import android.test.AndroidTestCase;
-import android.util.Log;
-import android.webkit.CacheManager.CacheResult;
-import android.webkit.PluginData;
-import android.webkit.UrlInterceptHandler;
-
-import java.util.LinkedList;
-import java.util.Map;
-
-public class UrlInterceptRegistryTest extends AndroidTestCase {
-
- /**
- * To run these tests: $ mmm
- * frameworks/base/tests/CoreTests/android && adb remount && adb
- * sync $ adb shell am instrument -w -e class \
- * android.webkit.UrlInterceptRegistryTest \
- * android.core/android.test.InstrumentationTestRunner
- */
-
- private static class MockUrlInterceptHandler implements UrlInterceptHandler {
- private PluginData mData;
- private String mUrl;
-
- public MockUrlInterceptHandler(PluginData data, String url) {
- mData = data;
- mUrl = url;
- }
-
- public CacheResult service(String url, Map<String, String> headers) {
- return null;
- }
-
- public PluginData getPluginData(String url,
- Map<String,
- String> headers) {
- if (mUrl.equals(url)) {
- return mData;
- }
-
- return null;
- }
- }
-
- public void testGetPluginData() {
- PluginData data = new PluginData(null, 0 , null, 200);
- String url = new String("url1");
- MockUrlInterceptHandler handler1 =
- new MockUrlInterceptHandler(data, url);
-
- data = new PluginData(null, 0 , null, 404);
- url = new String("url2");
- MockUrlInterceptHandler handler2 =
- new MockUrlInterceptHandler(data, url);
-
- assertTrue(UrlInterceptRegistry.registerHandler(handler1));
- assertTrue(UrlInterceptRegistry.registerHandler(handler2));
-
- data = UrlInterceptRegistry.getPluginData("url1", null);
- assertTrue(data != null);
- assertTrue(data.getStatusCode() == 200);
-
- data = UrlInterceptRegistry.getPluginData("url2", null);
- assertTrue(data != null);
- assertTrue(data.getStatusCode() == 404);
-
- assertTrue(UrlInterceptRegistry.unregisterHandler(handler1));
- assertTrue(UrlInterceptRegistry.unregisterHandler(handler2));
-
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/ATResponseParserTest.java b/tests/CoreTests/com/android/internal/telephony/ATResponseParserTest.java
deleted file mode 100644
index 81727e4..0000000
--- a/tests/CoreTests/com/android/internal/telephony/ATResponseParserTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class ATResponseParserTest extends TestCase {
- @SmallTest
- public void testBasic() throws Exception {
- ATResponseParser p = new ATResponseParser("+CREG: 0");
-
- assertEquals(0, p.nextInt());
-
- assertFalse(p.hasMore());
-
- try {
- p.nextInt();
- fail("exception expected");
- } catch (ATParseEx ex) {
- //test pass
- }
-
- p = new ATResponseParser("+CREG: 0,1");
- assertEquals(0, p.nextInt());
- assertEquals(1, p.nextInt());
- assertFalse(p.hasMore());
-
- p = new ATResponseParser("+CREG: 0, 1");
- assertEquals(0, p.nextInt());
- assertEquals(1, p.nextInt());
- assertFalse(p.hasMore());
-
- p = new ATResponseParser("+CREG: 0, 1,");
- assertEquals(0, p.nextInt());
- assertEquals(1, p.nextInt());
- // this seems odd but is probably OK
- assertFalse(p.hasMore());
- try {
- p.nextInt();
- fail("exception expected");
- } catch (ATParseEx ex) {
- //test pass
- }
-
- p = new ATResponseParser("+CREG: 0, 1 ");
- assertEquals(0, p.nextInt());
- assertEquals(1, p.nextInt());
- assertFalse(p.hasMore());
-
- p = new ATResponseParser("0, 1 ");
- // no prefix -> exception
- try {
- p.nextInt();
- fail("exception expected");
- } catch (ATParseEx ex) {
- //test pass
- }
-
- p = new ATResponseParser("+CREG: 0, 1, 5");
- assertFalse(p.nextBoolean());
- assertTrue(p.nextBoolean());
- try {
- // is this over-constraining?
- p.nextBoolean();
- fail("exception expected");
- } catch (ATParseEx ex) {
- //test pass
- }
-
- p = new ATResponseParser("+CLCC: 1,0,2,0,0,\"+18005551212\",145");
-
- assertEquals(1, p.nextInt());
- assertFalse(p.nextBoolean());
- assertEquals(2, p.nextInt());
- assertEquals(0, p.nextInt());
- assertEquals(0, p.nextInt());
- assertEquals("+18005551212", p.nextString());
- assertEquals(145, p.nextInt());
- assertFalse(p.hasMore());
-
- p = new ATResponseParser("+CLCC: 1,0,2,0,0,\"+18005551212,145");
-
- assertEquals(1, p.nextInt());
- assertFalse(p.nextBoolean());
- assertEquals(2, p.nextInt());
- assertEquals(0, p.nextInt());
- assertEquals(0, p.nextInt());
- try {
- p.nextString();
- fail("expected ex");
- } catch (ATParseEx ex) {
- //test pass
- }
-
- p = new ATResponseParser("+FOO: \"\"");
- assertEquals("", p.nextString());
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/AdnRecordTest.java b/tests/CoreTests/com/android/internal/telephony/AdnRecordTest.java
deleted file mode 100644
index 8a4a285..0000000
--- a/tests/CoreTests/com/android/internal/telephony/AdnRecordTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * {@hide}
- */
-public class AdnRecordTest extends TestCase {
-
- @SmallTest
- public void testBasic() throws Exception {
- AdnRecord adn;
-
- //
- // Typical record
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C07918150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("+18056377243", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // Empty records, empty strings
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
-
- assertEquals("", adn.getAlphaTag());
- assertEquals("", adn.getNumber());
- assertTrue(adn.isEmpty());
-
- //
- // Record too short
- //
- adn = new AdnRecord(IccUtils.hexStringToBytes( "FF"));
-
- assertEquals("", adn.getAlphaTag());
- assertEquals("", adn.getNumber());
- assertTrue(adn.isEmpty());
-
- //
- // TOA = 0xff ("control string")
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C07FF8150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("18056377243", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // TOA = 0x81 (unknown)
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C07818150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("18056377243", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // Number Length is too long
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C0F918150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // Number Length is zero (invalid)
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C00918150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // Number Length is 2, first number byte is FF, TOA is international
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C0291FF50367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // Number Length is 2, first number digit is valid, TOA is international
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes("566F696365204D61696C0291F150367742F3FFFFFFFFFFFF"));
-
- assertEquals("Voice Mail", adn.getAlphaTag());
- assertEquals("+1", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // An extended record
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes(
- "4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678", adn.getNumber());
- assertFalse(adn.isEmpty());
- assertTrue(adn.hasExtendedRecord());
-
- adn.appendExtRecord(IccUtils.hexStringToBytes("0206092143658709ffffffffff"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678901234567890", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // An extended record with an invalid extension
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes(
- "4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678", adn.getNumber());
- assertFalse(adn.isEmpty());
- assertTrue(adn.hasExtendedRecord());
-
- adn.appendExtRecord(IccUtils.hexStringToBytes("0106092143658709ffffffffff"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678", adn.getNumber());
- assertFalse(adn.isEmpty());
-
- //
- // An extended record with an invalid extension
- //
- adn = new AdnRecord(
- IccUtils.hexStringToBytes(
- "4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678", adn.getNumber());
- assertFalse(adn.isEmpty());
- assertTrue(adn.hasExtendedRecord());
-
- adn.appendExtRecord(IccUtils.hexStringToBytes("020B092143658709ffffffffff"));
-
- assertEquals("Adgjm", adn.getAlphaTag());
- assertEquals("+18885551212,12345678", adn.getNumber());
- assertFalse(adn.isEmpty());
- }
-}
-
-
diff --git a/tests/CoreTests/com/android/internal/telephony/GsmAlphabetTest.java b/tests/CoreTests/com/android/internal/telephony/GsmAlphabetTest.java
deleted file mode 100644
index 3a9c511..0000000
--- a/tests/CoreTests/com/android/internal/telephony/GsmAlphabetTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import junit.framework.TestCase;
-
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-public class GsmAlphabetTest extends TestCase {
-
- private static final String sGsmExtendedChars = "{|}\\[~]\f\u20ac";
-
- @SmallTest
- public void test7bitWithHeader() throws Exception {
- SmsHeader.ConcatRef concatRef = new SmsHeader.ConcatRef();
- concatRef.refNumber = 1;
- concatRef.seqNumber = 2;
- concatRef.msgCount = 2;
- concatRef.isEightBits = true;
- SmsHeader header = new SmsHeader();
- header.concatRef = concatRef;
-
- String message = "aaaaaaaaaabbbbbbbbbbcccccccccc";
- byte[] userData = GsmAlphabet.stringToGsm7BitPackedWithHeader(message,
- SmsHeader.toByteArray(header));
- int septetCount = GsmAlphabet.countGsmSeptets(message, false);
- String parsedMessage = GsmAlphabet.gsm7BitPackedToString(
- userData, SmsHeader.toByteArray(header).length+2, septetCount, 1);
- assertEquals(message, parsedMessage);
- }
-
- // TODO: This method should *really* be a series of individual test methods.
- @LargeTest
- public void testBasic() throws Exception {
- // '@' maps to char 0
- assertEquals(0, GsmAlphabet.charToGsm('@'));
-
- // `a (a with grave accent) maps to last GSM charater
- assertEquals(0x7f, GsmAlphabet.charToGsm('\u00e0'));
-
- //
- // These are the extended chars
- // They should all return GsmAlphabet.GSM_EXTENDED_ESCAPE
- //
-
- for (int i = 0, s = sGsmExtendedChars.length(); i < s; i++) {
- assertEquals(GsmAlphabet.GSM_EXTENDED_ESCAPE,
- GsmAlphabet.charToGsm(sGsmExtendedChars.charAt(i)));
-
- }
-
- // euro symbol
- assertEquals(GsmAlphabet.GSM_EXTENDED_ESCAPE,
- GsmAlphabet.charToGsm('\u20ac'));
-
- // An unmappable char (the 'cent' char) maps to a space
- assertEquals(GsmAlphabet.charToGsm(' '),
- GsmAlphabet.charToGsm('\u00a2'));
-
- // unmappable = space = 1 septet
- assertEquals(1, GsmAlphabet.countGsmSeptets('\u00a2'));
-
- //
- // Test extended table
- //
-
- for (int i = 0, s = sGsmExtendedChars.length(); i < s; i++) {
- assertEquals(sGsmExtendedChars.charAt(i),
- GsmAlphabet.gsmExtendedToChar(
- GsmAlphabet.charToGsmExtended(sGsmExtendedChars.charAt(i))));
-
- }
-
- // Unmappable extended char
- assertEquals(GsmAlphabet.charToGsm(' '),
- GsmAlphabet.charToGsmExtended('@'));
-
- //
- // gsmToChar()
- //
-
- assertEquals('@', GsmAlphabet.gsmToChar(0));
-
- // `a (a with grave accent) maps to last GSM charater
- assertEquals('\u00e0', GsmAlphabet.gsmToChar(0x7f));
-
- assertEquals('\uffff',
- GsmAlphabet.gsmToChar(GsmAlphabet.GSM_EXTENDED_ESCAPE));
-
- // Out-of-range/unmappable value
- assertEquals(' ', GsmAlphabet.gsmToChar(0x80));
-
- //
- // gsmExtendedToChar()
- //
-
- assertEquals('{', GsmAlphabet.gsmExtendedToChar(0x28));
-
- // No double-escapes
- assertEquals(' ', GsmAlphabet.gsmExtendedToChar(
- GsmAlphabet.GSM_EXTENDED_ESCAPE));
-
- // Unmappable
- assertEquals(' ', GsmAlphabet.gsmExtendedToChar(0));
-
- //
- // stringTo7BitPacked, gsm7BitPackedToString
- //
-
- byte[] packed;
- StringBuilder testString = new StringBuilder(300);
-
- // Check all alignment cases
- for (int i = 0; i < 9; i++, testString.append('@')) {
- packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- assertEquals(testString.toString(),
- GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
- }
-
- // Check full non-extended alphabet
- for (int i = 0; i < 0x80; i++) {
- char c;
-
- if (i == GsmAlphabet.GSM_EXTENDED_ESCAPE) {
- continue;
- }
-
- c = GsmAlphabet.gsmToChar(i);
- testString.append(c);
-
- // These are all non-extended chars, so it should be
- // one septet per char
- assertEquals(1, GsmAlphabet.countGsmSeptets(c));
- }
-
- packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- assertEquals(testString.toString(),
- GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
-
- // Test extended chars too
-
- testString.append(sGsmExtendedChars);
-
- for (int i = 0, s = sGsmExtendedChars.length(); i < s; i++) {
- // These are all extended chars, so it should be
- // two septets per char
- assertEquals(2, GsmAlphabet.countGsmSeptets(sGsmExtendedChars.charAt(i)));
-
- }
-
- packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- assertEquals(testString.toString(),
- GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
-
- // stringTo7BitPacked handles up to 255 septets
-
- testString.setLength(0);
- for (int i = 0; i < 255; i++) {
- testString.append('@');
- }
-
- packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- assertEquals(testString.toString(),
- GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
-
- // > 255 septets throws runtime exception
- testString.append('@');
-
- try {
- GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- fail("expected exception");
- } catch (EncodeException ex) {
- // exception expected
- }
-
- // Try 254 septets with 127 extended chars
-
- testString.setLength(0);
- for (int i = 0; i < (255 / 2); i++) {
- testString.append('{');
- }
-
- packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- assertEquals(testString.toString(),
- GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
-
- // > 255 septets throws runtime exception
- testString.append('{');
-
- try {
- GsmAlphabet.stringToGsm7BitPacked(testString.toString());
- fail("expected exception");
- } catch (EncodeException ex) {
- // exception expected
- }
-
- //
- // 8 bit unpacked format
- //
- // Note: we compare hex strings here
- // because Assert doesnt have array-comparisons
-
- byte unpacked[];
-
- unpacked = IccUtils.hexStringToBytes("566F696365204D61696C");
- assertEquals("Voice Mail",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- assertEquals(IccUtils.bytesToHexString(unpacked),
- IccUtils.bytesToHexString(
- GsmAlphabet.stringToGsm8BitPacked("Voice Mail")));
-
- unpacked = GsmAlphabet.stringToGsm8BitPacked(sGsmExtendedChars);
- // two bytes for every extended char
- assertEquals(2 * sGsmExtendedChars.length(), unpacked.length);
- assertEquals(sGsmExtendedChars,
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- // should be two bytes per extended char
- assertEquals(2 * sGsmExtendedChars.length(), unpacked.length);
-
- // Test truncation of unaligned extended chars
- unpacked = new byte[3];
- GsmAlphabet.stringToGsm8BitUnpackedField(sGsmExtendedChars, unpacked,
- 0, unpacked.length);
-
- // Should be one extended char and an 0xff at the end
-
- assertEquals(0xff, 0xff & unpacked[2]);
- assertEquals(sGsmExtendedChars.substring(0, 1),
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- // Test truncation of normal chars
- unpacked = new byte[3];
- GsmAlphabet.stringToGsm8BitUnpackedField("abcd", unpacked,
- 0, unpacked.length);
-
- assertEquals("abc",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- // Test truncation of mixed normal and extended chars
- unpacked = new byte[3];
- GsmAlphabet.stringToGsm8BitUnpackedField("a{cd", unpacked,
- 0, unpacked.length);
-
- assertEquals("a{",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- // Test padding after normal char
- unpacked = new byte[3];
- GsmAlphabet.stringToGsm8BitUnpackedField("a", unpacked,
- 0, unpacked.length);
-
- assertEquals("a",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- assertEquals(0xff, 0xff & unpacked[1]);
- assertEquals(0xff, 0xff & unpacked[2]);
-
- // Test malformed input -- escape char followed by end of field
- unpacked[0] = 0;
- unpacked[1] = 0;
- unpacked[2] = GsmAlphabet.GSM_EXTENDED_ESCAPE;
-
- assertEquals("@@",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
-
- // non-zero offset
- assertEquals("@",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
-
- // test non-zero offset
- unpacked[0] = 0;
- GsmAlphabet.stringToGsm8BitUnpackedField("abcd", unpacked,
- 1, unpacked.length - 1);
-
-
- assertEquals(0, unpacked[0]);
-
- assertEquals("ab",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
-
- // test non-zero offset with truncated extended char
- unpacked[0] = 0;
-
- GsmAlphabet.stringToGsm8BitUnpackedField("a{", unpacked,
- 1, unpacked.length - 1);
-
- assertEquals(0, unpacked[0]);
-
- assertEquals("a",
- GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java
deleted file mode 100644
index aa2981b..0000000
--- a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.SpannableStringBuilder;
-import android.telephony.PhoneNumberUtils;
-
-import junit.framework.TestCase;
-
-public class PhoneNumberUtilsTest extends TestCase {
-
- @SmallTest
- public void testExtractNetworkPortion() throws Exception {
- assertEquals(
- "+17005554141",
- PhoneNumberUtils.extractNetworkPortion("+17005554141")
- );
-
- assertEquals(
- "+17005554141",
- PhoneNumberUtils.extractNetworkPortion("+1 (700).555-4141")
- );
-
- assertEquals(
- "17005554141",
- PhoneNumberUtils.extractNetworkPortion("1 (700).555-4141")
- );
-
- // This may seem wrong, but it's probably ok
- assertEquals(
- "17005554141*#",
- PhoneNumberUtils.extractNetworkPortion("1 (700).555-4141*#")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortion("1 (700).555-41NN")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortion("1 (700).555-41NN,1234")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortion("1 (700).555-41NN;1234")
- );
-
- // An MMI string is unperterbed, even though it contains a
- // (valid in this case) embedded +
- assertEquals(
- "**21**17005554141#",
- PhoneNumberUtils.extractNetworkPortion("**21**+17005554141#")
- //TODO this is the correct result, although the above
- //result has been returned since change 31776
- //"**21**+17005554141#"
- );
-
- assertEquals("", PhoneNumberUtils.extractNetworkPortion(""));
-
- assertEquals("", PhoneNumberUtils.extractNetworkPortion(",1234"));
-
- byte [] b = new byte[20];
- b[0] = (byte) 0x81; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
- b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xF0;
- assertEquals("17005550020",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
- b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xF0;
- assertEquals("+17005550020",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
-
- byte[] bRet = PhoneNumberUtils.networkPortionToCalledPartyBCD("+17005550020");
- assertEquals(7, bRet.length);
- for (int i = 0; i < 7; i++) {
- assertEquals(b[i], bRet[i]);
- }
-
- bRet = PhoneNumberUtils.networkPortionToCalledPartyBCDWithLength("+17005550020");
- assertEquals(8, bRet.length);
- assertEquals(bRet[0], 7);
- for (int i = 1; i < 8; i++) {
- assertEquals(b[i - 1], bRet[i]);
- }
-
- bRet = PhoneNumberUtils.networkPortionToCalledPartyBCD("7005550020");
- assertEquals("7005550020",
- PhoneNumberUtils.calledPartyBCDToString(bRet, 0, bRet.length));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
- b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xB0;
- assertEquals("17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
- b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xB0;
- assertEquals("+17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0x2A; b[2] = (byte) 0xB1;
- assertEquals("*21#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 3));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0x2B; b[2] = (byte) 0xB1;
- assertEquals("#21#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 3));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0x2A; b[2] = (byte) 0xB1;
- assertEquals("*21#+",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 3));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0xAA; b[2] = (byte) 0x12; b[3] = (byte) 0xFB;
- assertEquals("**21#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 4));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0xAA; b[2] = (byte) 0x12; b[3] = (byte) 0xFB;
- assertEquals("**21#+",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 4));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0x9A; b[2] = (byte) 0xA9; b[3] = (byte) 0x71;
- b[4] = (byte) 0x00; b[5] = (byte) 0x55; b[6] = (byte) 0x05; b[7] = (byte) 0x20;
- b[8] = (byte) 0xB0;
- assertEquals("*99*17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 9));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0x9A; b[2] = (byte) 0xA9; b[3] = (byte) 0x71;
- b[4] = (byte) 0x00; b[5] = (byte) 0x55; b[6] = (byte) 0x05; b[7] = (byte) 0x20;
- b[8] = (byte) 0xB0;
- assertEquals("*99*+17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 9));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0xAA; b[2] = (byte) 0x12; b[3] = (byte) 0x1A;
- b[4] = (byte) 0x07; b[5] = (byte) 0x50; b[6] = (byte) 0x55; b[7] = (byte) 0x00;
- b[8] = (byte) 0x02; b[9] = (byte) 0xFB;
- assertEquals("**21*17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 10));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0xAA; b[2] = (byte) 0x12; b[3] = (byte) 0x1A;
- b[4] = (byte) 0x07; b[5] = (byte) 0x50; b[6] = (byte) 0x55; b[7] = (byte) 0x00;
- b[8] = (byte) 0x02; b[9] = (byte) 0xFB;
- assertEquals("**21*+17005550020#",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 10));
-
- b[0] = (byte) 0x81; b[1] = (byte) 0x2A; b[2] = (byte) 0xA1; b[3] = (byte) 0x71;
- b[4] = (byte) 0x00; b[5] = (byte) 0x55; b[6] = (byte) 0x05; b[7] = (byte) 0x20;
- b[8] = (byte) 0xF0;
- assertEquals("*21*17005550020",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 9));
-
- b[0] = (byte) 0x91; b[1] = (byte) 0x2A; b[2] = (byte) 0xB1; b[3] = (byte) 0x71;
- b[4] = (byte) 0x00; b[5] = (byte) 0x55; b[6] = (byte) 0x05; b[7] = (byte) 0x20;
- b[8] = (byte) 0xF0;
- assertEquals("*21#+17005550020",
- PhoneNumberUtils.calledPartyBCDToString(b, 0, 9));
-
- assertNull(PhoneNumberUtils.extractNetworkPortion(null));
- assertNull(PhoneNumberUtils.extractPostDialPortion(null));
- assertTrue(PhoneNumberUtils.compare(null, null));
- assertFalse(PhoneNumberUtils.compare(null, "123"));
- assertFalse(PhoneNumberUtils.compare("123", null));
- assertNull(PhoneNumberUtils.toCallerIDMinMatch(null));
- assertNull(PhoneNumberUtils.getStrippedReversed(null));
- assertNull(PhoneNumberUtils.stringFromStringAndTOA(null, 1));
- }
-
- @SmallTest
- public void testExtractNetworkPortionAlt() throws Exception {
- assertEquals(
- "+17005554141",
- PhoneNumberUtils.extractNetworkPortionAlt("+17005554141")
- );
-
- assertEquals(
- "+17005554141",
- PhoneNumberUtils.extractNetworkPortionAlt("+1 (700).555-4141")
- );
-
- assertEquals(
- "17005554141",
- PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141")
- );
-
- // This may seem wrong, but it's probably ok
- assertEquals(
- "17005554141*#",
- PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141*#")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN,1234")
- );
-
- assertEquals(
- "170055541NN",
- PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN;1234")
- );
-
- // An MMI string is unperterbed, even though it contains a
- // (valid in this case) embedded +
- assertEquals(
- "**21**+17005554141#",
- PhoneNumberUtils.extractNetworkPortionAlt("**21**+17005554141#")
- );
-
- assertEquals(
- "*31#+447966164208",
- PhoneNumberUtils.extractNetworkPortionAlt("*31#+447966164208")
- );
-
- assertEquals(
- "*31#+447966164208",
- PhoneNumberUtils.extractNetworkPortionAlt("*31# (+44) 79 6616 4208")
- );
-
- assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(""));
-
- assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(",1234"));
-
- assertNull(PhoneNumberUtils.extractNetworkPortionAlt(null));
- }
-
- @SmallTest
- public void testB() throws Exception {
- assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141"));
- assertEquals("", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-4141"));
- assertEquals("", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN"));
- assertEquals(",1234", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN,1234"));
- assertEquals(";1234", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN;1234"));
- assertEquals(";1234,;N",
- PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN;1-2.34 ,;N"));
- }
-
- @SmallTest
- public void testCompare() throws Exception {
- // this is odd
- assertFalse(PhoneNumberUtils.compare("", ""));
-
- assertTrue(PhoneNumberUtils.compare("911", "911"));
- assertFalse(PhoneNumberUtils.compare("911", "18005550911"));
- assertTrue(PhoneNumberUtils.compare("5555", "5555"));
- assertFalse(PhoneNumberUtils.compare("5555", "180055555555"));
-
- assertTrue(PhoneNumberUtils.compare("+17005554141", "+17005554141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "+1 (700).555-4141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "+1 (700).555-4141,1234"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "17005554141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "7005554141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "5554141"));
- assertTrue(PhoneNumberUtils.compare("17005554141", "5554141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "01117005554141"));
- assertTrue(PhoneNumberUtils.compare("+17005554141", "0017005554141"));
- assertTrue(PhoneNumberUtils.compare("17005554141", "0017005554141"));
-
-
- assertTrue(PhoneNumberUtils.compare("+17005554141", "**31#+17005554141"));
-
- assertFalse(PhoneNumberUtils.compare("+1 999 7005554141", "+1 7005554141"));
- assertTrue(PhoneNumberUtils.compare("011 1 7005554141", "7005554141"));
-
- assertFalse(PhoneNumberUtils.compare("011 11 7005554141", "+17005554141"));
-
- assertFalse(PhoneNumberUtils.compare("+17005554141", "7085882300"));
-
- assertTrue(PhoneNumberUtils.compare("+44 207 792 3490", "0 207 792 3490"));
-
- assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "00 207 792 3490"));
- assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "011 207 792 3490"));
-
- /***** FIXME's ******/
- //
- // MMI header should be ignored
- assertFalse(PhoneNumberUtils.compare("+17005554141", "**31#17005554141"));
-
- // It's too bad this is false
- // +44 (0) 207 792 3490 is not a dialable number
- // but it is commonly how European phone numbers are written
- assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "+44 (0) 207 792 3490"));
-
- // The japanese international prefix, for example, messes us up
- // But who uses a GSM phone in Japan?
- assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "010 44 207 792 3490"));
-
- // The Australian one messes us up too
- assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "0011 44 207 792 3490"));
-
- // The Russian trunk prefix messes us up, as does current
- // Russian area codes (which bein with 0)
-
- assertFalse(PhoneNumberUtils.compare("+7(095)9100766", "8(095)9100766"));
-
- // 444 is not a valid country code, but
- // matchIntlPrefixAndCC doesnt know this
- assertTrue(PhoneNumberUtils.compare("+444 207 792 3490", "0 207 792 3490"));
-
- // compare SMS short code
- assertTrue(PhoneNumberUtils.compare("404-04", "40404"));
- }
-
-
- @SmallTest
- public void testToCallerIDIndexable() throws Exception {
- assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("17005554141"));
- assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141"));
- assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141,1234"));
- assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141;1234"));
-
- //this seems wrong, or at least useless
- assertEquals("NN14555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-41NN"));
-
- //<shrug> -- these are all not useful, but not terribly wrong
- assertEquals("", PhoneNumberUtils.toCallerIDMinMatch(""));
- assertEquals("0032", PhoneNumberUtils.toCallerIDMinMatch("2300"));
- assertEquals("0032+", PhoneNumberUtils.toCallerIDMinMatch("+2300"));
- assertEquals("#130#*", PhoneNumberUtils.toCallerIDMinMatch("*#031#"));
- }
-
- @SmallTest
- public void testGetIndexable() throws Exception {
- assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141"));
- assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141,1234"));
- assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141;1234"));
-
- //this seems wrong, or at least useless
- assertEquals("NN145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-41NN"));
-
- //<shrug> -- these are all not useful, but not terribly wrong
- assertEquals("", PhoneNumberUtils.getStrippedReversed(""));
- assertEquals("0032", PhoneNumberUtils.getStrippedReversed("2300"));
- assertEquals("0032+", PhoneNumberUtils.getStrippedReversed("+2300"));
- assertEquals("#130#*", PhoneNumberUtils.getStrippedReversed("*#031#"));
- }
-
- @SmallTest
- public void testNanpFormatting() {
- SpannableStringBuilder number = new SpannableStringBuilder();
- number.append("8005551212");
- PhoneNumberUtils.formatNanpNumber(number);
- assertEquals("800-555-1212", number.toString());
-
- number.clear();
- number.append("800555121");
- PhoneNumberUtils.formatNanpNumber(number);
- assertEquals("800-555-121", number.toString());
-
- number.clear();
- number.append("555-1212");
- PhoneNumberUtils.formatNanpNumber(number);
- assertEquals("555-1212", number.toString());
-
- number.clear();
- number.append("800-55512");
- PhoneNumberUtils.formatNanpNumber(number);
- assertEquals("800-555-12", number.toString());
-
- number.clear();
- number.append("46645");
- PhoneNumberUtils.formatNanpNumber(number);
- assertEquals("46645", number.toString());
- }
-
- @SmallTest
- public void testConvertKeypadLettersToDigits() {
- assertEquals("1-800-4664-411",
- PhoneNumberUtils.convertKeypadLettersToDigits("1-800-GOOG-411"));
- assertEquals("18004664411",
- PhoneNumberUtils.convertKeypadLettersToDigits("1800GOOG411"));
- assertEquals("1-800-466-4411",
- PhoneNumberUtils.convertKeypadLettersToDigits("1-800-466-4411"));
- assertEquals("18004664411",
- PhoneNumberUtils.convertKeypadLettersToDigits("18004664411"));
- assertEquals("222-333-444-555-666-7777-888-9999",
- PhoneNumberUtils.convertKeypadLettersToDigits(
- "ABC-DEF-GHI-JKL-MNO-PQRS-TUV-WXYZ"));
- assertEquals("222-333-444-555-666-7777-888-9999",
- PhoneNumberUtils.convertKeypadLettersToDigits(
- "abc-def-ghi-jkl-mno-pqrs-tuv-wxyz"));
- assertEquals("(800) 222-3334",
- PhoneNumberUtils.convertKeypadLettersToDigits("(800) ABC-DEFG"));
- }
-
- @SmallTest
- public void testCheckAndProcessPlusCode() {
- assertEquals("0118475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+8475797000"));
- assertEquals("18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+18475797000"));
- assertEquals("0111234567",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+1234567"));
- assertEquals("01123456700000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+23456700000"));
- assertEquals("01111875767800",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+11875767800"));
- assertEquals("8475797000,18475231753",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,+18475231753"));
- assertEquals("0118475797000,18475231753",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+8475797000,+18475231753"));
- assertEquals("8475797000;0118469312345",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000;+8469312345"));
- assertEquals("8475797000,0111234567",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,+1234567"));
- assertEquals("847597000;01111875767000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("847597000;+11875767000"));
- assertEquals("8475797000,,0118469312345",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,,+8469312345"));
- assertEquals("8475797000;,0118469312345",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000;,+8469312345"));
- assertEquals("8475797000,;18475231753",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,;+18475231753"));
- assertEquals("8475797000;,01111875767000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000;,+11875767000"));
- assertEquals("8475797000,;01111875767000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,;+11875767000"));
- assertEquals("8475797000,,,01111875767000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,,,+11875767000"));
- assertEquals("8475797000;,,01111875767000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000;,,+11875767000"));
- assertEquals("+;,8475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+;,8475797000"));
- assertEquals("8475797000,",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("8475797000,"));
- assertEquals("847+579-7000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("847+579-7000"));
- assertEquals(",8475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode(",8475797000"));
- assertEquals(";;8475797000,,",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode(";;8475797000,,"));
- assertEquals("+this+is$weird;,+",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+this+is$weird;,+"));
- assertEquals("",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCode(""));
- assertNull(PhoneNumberUtils.cdmaCheckAndProcessPlusCode(null));
- }
-
- @SmallTest
- public void testCheckAndProcessPlusCodeByNumberFormat() {
- assertEquals("18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("+18475797000",
- PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_NANP));
- assertEquals("+18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("+18475797000",
- PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_JAPAN));
- assertEquals("+18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("+18475797000",
- PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_UNKNOWN));
- assertEquals("+18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("+18475797000",
- PhoneNumberUtils.FORMAT_JAPAN,PhoneNumberUtils.FORMAT_JAPAN));
- assertEquals("+18475797000",
- PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("+18475797000",
- PhoneNumberUtils.FORMAT_UNKNOWN,PhoneNumberUtils.FORMAT_UNKNOWN));
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/PhoneNumberWatcherTest.java b/tests/CoreTests/com/android/internal/telephony/PhoneNumberWatcherTest.java
deleted file mode 100644
index 88eaecd..0000000
--- a/tests/CoreTests/com/android/internal/telephony/PhoneNumberWatcherTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2008 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.internal.telephony;
-
-import android.telephony.PhoneNumberFormattingTextWatcher;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.Selection;
-import android.text.SpannableStringBuilder;
-import android.text.TextWatcher;
-
-import junit.framework.TestCase;
-
-public class PhoneNumberWatcherTest extends TestCase {
- @SmallTest
- public void testHyphenation() throws Exception {
- SpannableStringBuilder number = new SpannableStringBuilder();
- TextWatcher tw = new PhoneNumberFormattingTextWatcher();
- number.append("555-1212");
- // Move the cursor to the left edge
- Selection.setSelection(number, 0);
- tw.beforeTextChanged(number, 0, 0, 1);
- // Insert an 8 at the beginning
- number.insert(0, "8");
- tw.afterTextChanged(number);
- assertEquals("855-512-12", number.toString());
- }
-
- @SmallTest
- public void testHyphenDeletion() throws Exception {
- SpannableStringBuilder number = new SpannableStringBuilder();
- TextWatcher tw = new PhoneNumberFormattingTextWatcher();
- number.append("555-1212");
- // Move the cursor to after the hyphen
- Selection.setSelection(number, 4);
- // Delete the hyphen
- tw.beforeTextChanged(number, 3, 1, 0);
- number.delete(3, 4);
- tw.afterTextChanged(number);
- // Make sure that it deleted the character before the hyphen
- assertEquals("551-212", number.toString());
-
- // Make sure it deals with left edge boundary case
- number.insert(0, "-");
- Selection.setSelection(number, 1);
- tw.beforeTextChanged(number, 0, 1, 0);
- number.delete(0, 1);
- tw.afterTextChanged(number);
- // Make sure that it deleted the character before the hyphen
- assertEquals("551-212", number.toString());
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/SMSDispatcherTest.java b/tests/CoreTests/com/android/internal/telephony/SMSDispatcherTest.java
deleted file mode 100644
index 8a66614..0000000
--- a/tests/CoreTests/com/android/internal/telephony/SMSDispatcherTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2007 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.internal.telephony;
-
-import android.test.suitebuilder.annotation.MediumTest;
-import com.android.internal.telephony.TestPhoneNotifier;
-import com.android.internal.telephony.gsm.SmsMessage;
-import com.android.internal.telephony.test.SimulatedCommands;
-import com.android.internal.telephony.test.SimulatedRadioControl;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.Suppress;
-
-import java.util.Iterator;
-
-/**
- * {@hide}
- */
-public class SMSDispatcherTest extends AndroidTestCase {
- @MediumTest
- public void testCMT1() throws Exception {
- SmsMessage sms;
- SmsHeader header;
-
- String[] lines = new String[2];
-
- lines[0] = "+CMT: ,158";
- lines[1] = "07914140279510F6440A8111110301003BF56080426101748A8C0B05040B"
- + "8423F000035502010106276170706C69636174696F6E2F766E642E776170"
- + "2E6D6D732D6D65737361676500AF848D0185B4848C8298524F347839776F"
- + "7547514D4141424C3641414141536741415A4B554141414141008D908918"
- + "802B31363530323438363137392F545950453D504C4D4E008A808E028000"
- + "88058103093A8083687474703A2F2F36";
-
- sms = SmsMessage.newFromCMT(lines);
- header = sms.getUserDataHeader();
- assertNotNull(header);
- assertNotNull(sms.getUserData());
- assertNotNull(header.concatRef);
- assertEquals(header.concatRef.refNumber, 85);
- assertEquals(header.concatRef.msgCount, 2);
- assertEquals(header.concatRef.seqNumber, 1);
- assertEquals(header.concatRef.isEightBits, true);
- assertNotNull(header.portAddrs);
- assertEquals(header.portAddrs.destPort, 2948);
- assertEquals(header.portAddrs.origPort, 9200);
- assertEquals(header.portAddrs.areEightBits, false);
- }
-
- @MediumTest
- public void testCMT2() throws Exception {
- SmsMessage sms;
- SmsHeader header;
-
- String[] lines = new String[2];
-
- lines[0] = "+CMT: ,77";
- lines[1] = "07914140279510F6440A8111110301003BF56080426101848A3B0B05040B8423F"
- + "00003550202362E3130322E3137312E3135302F524F347839776F7547514D4141"
- + "424C3641414141536741415A4B55414141414100";
-
- sms = SmsMessage.newFromCMT(lines);
- header = sms.getUserDataHeader();
- assertNotNull(header);
- assertNotNull(sms.getUserData());
- assertNotNull(header.concatRef);
- assertEquals(header.concatRef.refNumber, 85);
- assertEquals(header.concatRef.msgCount, 2);
- assertEquals(header.concatRef.seqNumber, 2);
- assertEquals(header.concatRef.isEightBits, true);
- assertNotNull(header.portAddrs);
- assertEquals(header.portAddrs.destPort, 2948);
- assertEquals(header.portAddrs.origPort, 9200);
- assertEquals(header.portAddrs.areEightBits, false);
- }
-
- @MediumTest
- public void testEfRecord() throws Exception {
- SmsMessage sms;
-
- String s = "03029111000c9194981492631000f269206190022000a053e4534a05358bd3"
- + "69f05804259da0219418a40641536a110a0aea408080604028180e888462c1"
- + "50341c0f484432a1542c174c46b3e1743c9f9068442a994ea8946ac56ab95e"
- + "b0986c46abd96eb89c6ec7ebf97ec0a070482c1a8fc8a472c96c3a9fd0a874"
- + "4aad5aafd8ac76cbed7abfe0b0784c2e9bcfe8b47acd6ebbdff0b87c4eafdb"
- + "eff8bc7ecfeffbffffffffffffffffffffffffffff";
- byte[] data = IccUtils.hexStringToBytes(s);
-
- sms = SmsMessage.createFromEfRecord(1, data);
- assertNotNull(sms.getMessageBody());
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/SimPhoneBookTest.java b/tests/CoreTests/com/android/internal/telephony/SimPhoneBookTest.java
deleted file mode 100644
index 609e768..0000000
--- a/tests/CoreTests/com/android/internal/telephony/SimPhoneBookTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import android.os.ServiceManager;
-import android.test.suitebuilder.annotation.Suppress;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-@Suppress
-public class SimPhoneBookTest extends TestCase {
-
- public void testBasic() throws Exception {
- IIccPhoneBook simPhoneBook =
- IIccPhoneBook.Stub.asInterface(ServiceManager.getService("simphonebook"));
- assertNotNull(simPhoneBook);
-
- int size[] = simPhoneBook.getAdnRecordsSize(IccConstants.EF_ADN);
- assertNotNull(size);
- assertEquals(3, size.length);
- assertEquals(size[0] * size[2], size[1]);
- assertTrue(size[2] >= 100);
-
- List<AdnRecord> adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- // do it twice cause the second time shall read from cache only
- adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- assertNotNull(adnRecordList);
-
- // Test for phone book update
- int adnIndex, listIndex = 0;
- AdnRecord originalAdn = null;
- // We need to maintain the state of the SIM before and after the test.
- // Since this test doesn't mock the SIM we try to get a valid ADN record,
- // for 3 tries and if this fails, we bail out.
- for (adnIndex = 3 ; adnIndex >= 1; adnIndex--) {
- listIndex = adnIndex - 1; // listIndex is zero based.
- originalAdn = adnRecordList.get(listIndex);
- assertNotNull("Original Adn is Null.", originalAdn);
- assertNotNull("Original Adn alpha tag is null.", originalAdn.getAlphaTag());
- assertNotNull("Original Adn number is null.", originalAdn.getNumber());
-
- if (originalAdn.getNumber().length() > 0 &&
- originalAdn.getAlphaTag().length() > 0) {
- break;
- }
- }
- if (adnIndex == 0) return;
-
- AdnRecord emptyAdn = new AdnRecord("", "");
- AdnRecord firstAdn = new AdnRecord("John", "4085550101");
- AdnRecord secondAdn = new AdnRecord("Andy", "6505550102");
- String pin2 = null;
-
- // udpate by index
- boolean success = simPhoneBook.updateAdnRecordsInEfByIndex(IccConstants.EF_ADN,
- firstAdn.getAlphaTag(), firstAdn.getNumber(), adnIndex, pin2);
- adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- AdnRecord tmpAdn = adnRecordList.get(listIndex);
- assertTrue(success);
- assertTrue(firstAdn.isEqual(tmpAdn));
-
- // replace by search
- success = simPhoneBook.updateAdnRecordsInEfBySearch(IccConstants.EF_ADN,
- firstAdn.getAlphaTag(), firstAdn.getNumber(),
- secondAdn.getAlphaTag(), secondAdn.getNumber(), pin2);
- adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- tmpAdn = adnRecordList.get(listIndex);
- assertTrue(success);
- assertFalse(firstAdn.isEqual(tmpAdn));
- assertTrue(secondAdn.isEqual(tmpAdn));
-
- // erase be search
- success = simPhoneBook.updateAdnRecordsInEfBySearch(IccConstants.EF_ADN,
- secondAdn.getAlphaTag(), secondAdn.getNumber(),
- emptyAdn.getAlphaTag(), emptyAdn.getNumber(), pin2);
- adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- tmpAdn = adnRecordList.get(listIndex);
- assertTrue(success);
- assertTrue(tmpAdn.isEmpty());
-
- // restore the orginial adn
- success = simPhoneBook.updateAdnRecordsInEfByIndex(IccConstants.EF_ADN,
- originalAdn.getAlphaTag(), originalAdn.getNumber(), adnIndex,
- pin2);
- adnRecordList = simPhoneBook.getAdnRecordsInEf(IccConstants.EF_ADN);
- tmpAdn = adnRecordList.get(listIndex);
- assertTrue(success);
- assertTrue(originalAdn.isEqual(tmpAdn));
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/SimSmsTest.java b/tests/CoreTests/com/android/internal/telephony/SimSmsTest.java
deleted file mode 100644
index 1609680..0000000
--- a/tests/CoreTests/com/android/internal/telephony/SimSmsTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import android.os.ServiceManager;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class SimSmsTest extends TestCase {
-
- @MediumTest
- @Suppress // TODO: suppress this test for now since it doesn't work on the emulator
- public void testBasic() throws Exception {
-
- ISms sms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
- assertNotNull(sms);
-
- List<SmsRawData> records = sms.getAllMessagesFromIccEf();
- assertNotNull(records);
- assertTrue(records.size() >= 0);
-
- int firstNullIndex = -1;
- int firstValidIndex = -1;
- byte[] pdu = null;
- for (int i = 0; i < records.size(); i++) {
- SmsRawData data = records.get(i);
- if (data != null && firstValidIndex == -1) {
- firstValidIndex = i;
- pdu = data.getBytes();
- }
- if (data == null && firstNullIndex == -1) {
- firstNullIndex = i;
- }
- if (firstNullIndex != -1 && firstValidIndex != -1) {
- break;
- }
- }
- if (firstNullIndex == -1 || firstValidIndex == -1)
- return;
- assertNotNull(pdu);
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java
deleted file mode 100644
index db38ede..0000000
--- a/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import com.android.internal.telephony.gsm.SimTlv;
-import com.android.internal.telephony.IccUtils;
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-
-public class SimUtilsTest extends TestCase {
-
- @SmallTest
- public void testBasic() throws Exception {
- byte[] data, data2;
-
- /*
- * bcdToString()
- */
-
- // An EF[ICCID] record
- data = IccUtils.hexStringToBytes("981062400510444868f2");
- assertEquals("8901260450014484862", IccUtils.bcdToString(data, 0, data.length));
-
- // skip the first and last bytes
- assertEquals("0126045001448486", IccUtils.bcdToString(data, 1, data.length - 2));
-
- // Stops on invalid BCD value
- data = IccUtils.hexStringToBytes("98F062400510444868f2");
- assertEquals("890", IccUtils.bcdToString(data, 0, data.length));
-
- /*
- * gsmBcdByteToInt()
- */
-
- assertEquals(98, IccUtils.gsmBcdByteToInt((byte) 0x89));
-
- // Out of range is treated as 0
- assertEquals(8, IccUtils.gsmBcdByteToInt((byte) 0x8c));
-
- /*
- * cdmaBcdByteToInt()
- */
-
- assertEquals(89, IccUtils.cdmaBcdByteToInt((byte) 0x89));
-
- // Out of range is treated as 0
- assertEquals(80, IccUtils.cdmaBcdByteToInt((byte) 0x8c));
-
- /*
- * adnStringFieldToString()
- */
-
-
- data = IccUtils.hexStringToBytes("00566f696365204d61696c07918150367742f3ffffffffffff");
- // Again, skip prepended 0
- // (this is an EF[ADN] record)
- assertEquals("Voice Mail", IccUtils.adnStringFieldToString(data, 1, data.length - 15));
-
- data = IccUtils.hexStringToBytes("809673539A5764002F004DFFFFFFFFFF");
- // (this is from an EF[ADN] record)
- assertEquals("\u9673\u539A\u5764/M", IccUtils.adnStringFieldToString(data, 0, data.length));
-
- data = IccUtils.hexStringToBytes("810A01566fec6365204de0696cFFFFFF");
- // (this is made up to test since I don't have a real one)
- assertEquals("Vo\u00ECce M\u00E0il", IccUtils.adnStringFieldToString(data, 0, data.length));
-
- data = IccUtils.hexStringToBytes("820505302D82d32d31");
- // Example from 3GPP TS 11.11 V18.1.3.0 annex B
- assertEquals("-\u0532\u0583-1", IccUtils.adnStringFieldToString(data, 0, data.length));
- }
-
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/TelephonyTests.java b/tests/CoreTests/com/android/internal/telephony/TelephonyTests.java
deleted file mode 100644
index fdfafe1..0000000
--- a/tests/CoreTests/com/android/internal/telephony/TelephonyTests.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-import com.android.internal.telephony.AdnRecordTest;
-import com.android.internal.telephony.gsm.GSMPhoneTest;
-import com.android.internal.telephony.GsmAlphabetTest;
-import com.android.internal.telephony.SMSDispatcherTest;
-import com.android.internal.telephony.SimPhoneBookTest;
-import com.android.internal.telephony.SimSmsTest;
-import com.android.internal.telephony.SimUtilsTest;
-
-import junit.framework.TestSuite;
-
-/**
- * To run these tests:
- * $ mmm java/tests && adb sync
- * $ adb shell am instrument -w \
- * -e class com.android.internal.telephony.TelephonyTests \
- * android.core/android.test.InstrumentationTestRunner
- */
-public class TelephonyTests {
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(TelephonyTests.class.getName());
-
- suite.addTestSuite(PhoneNumberWatcherTest.class);
- suite.addTestSuite(ATResponseParserTest.class);
- suite.addTestSuite(PhoneNumberUtilsTest.class);
- suite.addTestSuite(SMSDispatcherTest.class);
- //suite.addTestSuite(GSMPhoneTest.class);
- suite.addTestSuite(AdnRecordTest.class);
- suite.addTestSuite(GsmAlphabetTest.class);
- suite.addTestSuite(SimUtilsTest.class);
- suite.addTestSuite(SimPhoneBookTest.class);
- suite.addTestSuite(SimSmsTest.class);
- suite.addTestSuite(TelephonyUtilsTest.class);
-
- return suite;
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java
deleted file mode 100644
index bf0c88b..0000000
--- a/tests/CoreTests/com/android/internal/telephony/TelephonyUtilsTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * Copyright (C) 2009 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.internal.telephony;
-
-import com.android.internal.telephony.RetryManager;
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class TelephonyUtilsTest extends TestCase {
-
- /**
- * After first creating the RetryManager
- * isRetryNeeded should be false and the time 0
- */
- @SmallTest
- public void testRetryManagerEmpty() throws Exception {
- RetryManager rm = new RetryManager();
-
- assertEquals(0, rm.getRetryCount());
- assertFalse(rm.isRetryForever());
- assertFalse(rm.isRetryNeeded());
- assertEquals(0, rm.getRetryCount());
- assertEquals(0, rm.getRetryTimer());
-
- rm.increaseRetryCount();
- assertFalse(rm.isRetryForever());
- assertFalse(rm.isRetryNeeded());
- assertEquals(0, rm.getRetryCount());
- assertEquals(0, rm.getRetryTimer());
-
- rm.setRetryCount(123);
- assertFalse(rm.isRetryForever());
- assertFalse(rm.isRetryNeeded());
- assertEquals(0, rm.getRetryCount());
- assertEquals(0, rm.getRetryTimer());
-
- rm.retryForeverUsingLastTimeout();
- assertTrue(rm.isRetryForever());
- assertTrue(rm.isRetryNeeded());
- assertEquals(0, rm.getRetryCount());
- assertEquals(0, rm.getRetryTimer());
-
- rm.setRetryCount(2);
- assertFalse(rm.isRetryForever());
- assertFalse(rm.isRetryNeeded());
- assertEquals(0, rm.getRetryCount());
- assertEquals(0, rm.getRetryTimer());
- }
-
- /**
- * A simple test and that randomization is doing something.
- */
- @SmallTest
- public void testRetryManagerSimplest() throws Exception {
- RetryManager rm = new RetryManager();
-
- assertTrue(rm.configure(1, 500, 10));
- int loops = 10;
- int count = 0;
- for (int i = 0; i < loops; i++) {
- assertTrue(rm.isRetryNeeded());
- int time = rm.getRetryTimer();
- assertTrue((time >= 500) && (time < 600));
- if (time == 500) {
- count++;
- }
- }
- assertFalse(count == loops);
- rm.increaseRetryCount();
- assertFalse(rm.isRetryNeeded());
- rm.setRetryCount(0);
- assertTrue(rm.isRetryNeeded());
- }
-
- /**
- * Test multiple values using simple configuration.
- */
- @SmallTest
- public void testRetryManagerSimple() throws Exception {
- RetryManager rm = new RetryManager();
-
- assertTrue(rm.configure(3, 1000, 0));
- assertTrue(rm.isRetryNeeded());
- assertEquals(1000, rm.getRetryTimer());
- assertEquals(rm.getRetryTimer(), 1000);
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- assertEquals(1000, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- assertEquals(1000, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertFalse(rm.isRetryNeeded());
- assertEquals(1000, rm.getRetryTimer());
- }
-
- /**
- * Test string configuration, simplest
- */
- @SmallTest
- public void testRetryManageSimpleString() throws Exception {
- RetryManager rm = new RetryManager();
-
- assertTrue(rm.configure("101"));
- assertTrue(rm.isRetryNeeded());
- assertEquals(101, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertFalse(rm.isRetryNeeded());
- }
-
- /**
- * Test infinite retires
- */
- @SmallTest
- public void testRetryManageInfinite() throws Exception {
- RetryManager rm = new RetryManager();
-
- assertTrue(rm.configure("1000,2000,3000,max_retries=infinite"));
- assertTrue(rm.isRetryNeeded());
- assertEquals(1000, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- assertEquals(2000, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- // All others are 3000 and isRetryNeeded is always true
- for (int i=0; i < 100; i++) {
- assertEquals(3000, rm.getRetryTimer());
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- }
- }
-
- /**
- * Test string configuration using all options.
- */
- @SmallTest
- public void testRetryManageString() throws Exception {
- RetryManager rm = new RetryManager();
- int time;
-
- assertTrue(rm.configure("max_retries=4,"
- + "default_randomization=100,1000, 2000 :200 , 3000"));
- assertTrue(rm.isRetryNeeded());
- time = rm.getRetryTimer();
- assertTrue((time >= 1000) && (time < 1100));
-
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- time = rm.getRetryTimer();
- assertTrue((time >= 2000) && (time < 2200));
-
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- time = rm.getRetryTimer();
- assertTrue((time >= 3000) && (time < 3100));
-
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- time = rm.getRetryTimer();
- assertTrue((time >= 3000) && (time < 3100));
-
- rm.increaseRetryCount();
- assertFalse(rm.isRetryNeeded());
- }
-
- /**
- * Test string configuration using all options.
- */
- @SmallTest
- public void testRetryManageForever() throws Exception {
- RetryManager rm = new RetryManager();
- int time;
-
- assertTrue(rm.configure("1000, 2000, 3000"));
- assertTrue(rm.isRetryNeeded());
- assertFalse(rm.isRetryForever());
- assertEquals(0, rm.getRetryCount());
- assertEquals(1000, rm.getRetryTimer());
-
- rm.retryForeverUsingLastTimeout();
- rm.increaseRetryCount();
- rm.increaseRetryCount();
- rm.increaseRetryCount();
- assertTrue(rm.isRetryNeeded());
- assertTrue(rm.isRetryForever());
- assertEquals(3, rm.getRetryCount());
- assertEquals(3000, rm.getRetryTimer());
-
- rm.setRetryCount(1);
- assertTrue(rm.isRetryNeeded());
- assertFalse(rm.isRetryForever());
- assertEquals(1, rm.getRetryCount());
- assertEquals(2000, rm.getRetryTimer());
-
- rm.retryForeverUsingLastTimeout();
- assertTrue(rm.isRetryNeeded());
- assertTrue(rm.isRetryForever());
- rm.resetRetryCount();
- assertTrue(rm.isRetryNeeded());
- assertFalse(rm.isRetryForever());
- assertEquals(0, rm.getRetryCount());
- assertEquals(1000, rm.getRetryTimer());
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/TestPhoneNotifier.java b/tests/CoreTests/com/android/internal/telephony/TestPhoneNotifier.java
deleted file mode 100644
index 427795b..0000000
--- a/tests/CoreTests/com/android/internal/telephony/TestPhoneNotifier.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2006 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.internal.telephony;
-
-/**
- * Stub class used for unit tests
- */
-
-public class TestPhoneNotifier implements PhoneNotifier {
- public TestPhoneNotifier() {
- }
-
- public void notifyPhoneState(Phone sender) {
- }
-
- public void notifyServiceState(Phone sender) {
- }
-
- public void notifyCellLocation(Phone sender) {
- }
-
- public void notifySignalStrength(Phone sender) {
- }
-
- public void notifyMessageWaitingChanged(Phone sender) {
- }
-
- public void notifyCallForwardingChanged(Phone sender) {
- }
-
- public void notifyDataConnection(Phone sender, String reason) {
- }
-
- public void notifyDataConnectionFailed(Phone sender, String reason) {
- }
-
- public void notifyDataActivity(Phone sender) {
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java b/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java
deleted file mode 100644
index b96743a..0000000
--- a/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java
+++ /dev/null
@@ -1,1938 +0,0 @@
-/*
- * Copyright (C) 2007 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 GSMTestHandler.ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony.gsm;
-
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.os.Process;
-import android.telephony.ServiceState;
-import android.test.AndroidTestCase;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-
-import com.android.internal.telephony.Call;
-import com.android.internal.telephony.CallStateException;
-import com.android.internal.telephony.Connection;
-import com.android.internal.telephony.MmiCode;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.TestPhoneNotifier;
-import com.android.internal.telephony.gsm.CallFailCause;
-import com.android.internal.telephony.gsm.GSMPhone;
-import com.android.internal.telephony.gsm.GSMTestHandler;
-import com.android.internal.telephony.gsm.GsmMmiCode;
-import com.android.internal.telephony.gsm.SuppServiceNotification;
-import com.android.internal.telephony.test.SimulatedCommands;
-import com.android.internal.telephony.test.SimulatedRadioControl;
-
-import java.util.List;
-
-
-public class GSMPhoneTest extends AndroidTestCase implements PerformanceTestCase {
- private SimulatedRadioControl mRadioControl;
- private GSMPhone mGSMPhone;
- private GSMTestHandler mGSMTestHandler;
- private Handler mHandler;
-
- private static final int EVENT_PHONE_STATE_CHANGED = 1;
- private static final int EVENT_DISCONNECT = 2;
- private static final int EVENT_RINGING = 3;
- private static final int EVENT_CHANNEL_OPENED = 4;
- private static final int EVENT_POST_DIAL = 5;
- private static final int EVENT_DONE = 6;
- private static final int EVENT_SSN = 7;
- private static final int EVENT_MMI_INITIATE = 8;
- private static final int EVENT_MMI_COMPLETE = 9;
- private static final int EVENT_IN_SERVICE = 10;
- private static final int SUPP_SERVICE_FAILED = 11;
- private static final int SERVICE_STATE_CHANGED = 12;
- private static final int EVENT_OEM_RIL_MESSAGE = 13;
- public static final int ANY_MESSAGE = -1;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mGSMTestHandler = new GSMTestHandler(mContext);
-
- mGSMTestHandler.start();
- synchronized (mGSMTestHandler) {
- do {
- mGSMTestHandler.wait();
- } while (mGSMTestHandler.getGSMPhone() == null);
- }
-
- mGSMPhone = mGSMTestHandler.getGSMPhone();
- mRadioControl = mGSMTestHandler.getSimulatedCommands();
-
- mHandler = mGSMTestHandler.getHandler();
- mGSMPhone.registerForPreciseCallStateChanged(mHandler, EVENT_PHONE_STATE_CHANGED, null);
- mGSMPhone.registerForNewRingingConnection(mHandler, EVENT_RINGING, null);
- mGSMPhone.registerForDisconnect(mHandler, EVENT_DISCONNECT, null);
-
- mGSMPhone.setOnPostDialCharacter(mHandler, EVENT_POST_DIAL, null);
-
- mGSMPhone.registerForSuppServiceNotification(mHandler, EVENT_SSN, null);
- mGSMPhone.registerForMmiInitiate(mHandler, EVENT_MMI_INITIATE, null);
- mGSMPhone.registerForMmiComplete(mHandler, EVENT_MMI_COMPLETE, null);
- mGSMPhone.registerForSuppServiceFailed(mHandler, SUPP_SERVICE_FAILED, null);
-
- mGSMPhone.registerForServiceStateChanged(mHandler, SERVICE_STATE_CHANGED, null);
-
- // wait until we get phone in both voice and data service
- Message msg;
- ServiceState state;
-
- do {
- msg = mGSMTestHandler.waitForMessage(SERVICE_STATE_CHANGED);
- assertNotNull("Message Time Out", msg);
- state = (ServiceState) ((AsyncResult) msg.obj).result;
- } while (state.getState() != ServiceState.STATE_IN_SERVICE);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mRadioControl.shutdown();
-
- mGSMPhone.unregisterForPreciseCallStateChanged(mHandler);
- mGSMPhone.unregisterForNewRingingConnection(mHandler);
- mGSMPhone.unregisterForDisconnect(mHandler);
- mGSMPhone.setOnPostDialCharacter(mHandler, 0, null);
- mGSMPhone.unregisterForSuppServiceNotification(mHandler);
- mGSMPhone.unregisterForMmiInitiate(mHandler);
- mGSMPhone.unregisterForMmiComplete(mHandler);
-
- mGSMPhone = null;
- mRadioControl = null;
- mHandler = null;
- mGSMTestHandler.cleanup();
-
- super.tearDown();
- }
-
- // These test can only be run once.
- public int startPerformance(Intermediates intermediates) {
- return 1;
- }
-
- public boolean isPerformanceOnly() {
- return false;
- }
-
-
- //This test is causing the emulator screen to turn off. I don't understand
- //why, but I'm removing it until we can figure it out.
- public void brokenTestGeneral() throws Exception {
- Connection cn;
- Message msg;
- AsyncResult ar;
-
- // IDLE state
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
- assertFalse(mGSMPhone.canConference());
-
- // One DIALING connection
-
- mRadioControl.setAutoProgressConnectingCall(false);
-
- mGSMPhone.dial("+13125551212");
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
-
- msg = mGSMTestHandler.waitForMessage(EVENT_PHONE_STATE_CHANGED);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertEquals(Call.State.DIALING, mGSMPhone.getForegroundCall().getState());
- assertTrue(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- /*do {
- mGSMTestHandler.waitForMessage(ANY_MESSAGE);
- } while (mGSMPhone.getForegroundCall().getConnections().size() == 0);*/
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DIALING,
- mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- cn = mGSMPhone.getForegroundCall().getConnections().get(0);
- assertTrue(!cn.isIncoming());
- assertEquals(Connection.PostDialState.NOT_STARTED, cn.getPostDialState());
-
- assertEquals(Connection.DisconnectCause.NOT_DISCONNECTED, cn.getDisconnectCause());
-
- assertFalse(mGSMPhone.canConference());
-
- // One ALERTING connection
-
- mRadioControl.progressConnectingCallState();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- }
- while (mGSMPhone.getForegroundCall().getState() != Call.State.ALERTING);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertTrue(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ALERTING, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- cn = mGSMPhone.getForegroundCall().getConnections().get(0);
- assertTrue(!cn.isIncoming());
- assertEquals(Connection.PostDialState.NOT_STARTED, cn.getPostDialState());
- assertFalse(mGSMPhone.canConference());
-
- // One ACTIVE connection
-
- mRadioControl.progressConnectingCallState();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertTrue(mGSMPhone.getForegroundCall().getEarliestConnectTime() > 0);
-
- cn = mGSMPhone.getForegroundCall().getConnections().get(0);
- assertTrue(!cn.isIncoming());
- assertEquals(Connection.PostDialState.COMPLETE, cn.getPostDialState());
- assertFalse(mGSMPhone.canConference());
-
- // One disconnected connection
- mGSMPhone.getForegroundCall().hangup();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertTrue(mGSMPhone.getForegroundCall().getEarliestConnectTime() > 0);
-
- assertFalse(mGSMPhone.canConference());
-
- cn = mGSMPhone.getForegroundCall().getEarliestConnection();
-
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- // Back to idle state
-
- mGSMPhone.clearDisconnected();
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- assertFalse(mGSMPhone.canConference());
-
- // cn left over from before phone.clearDisconnected();
-
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- // One ringing (INCOMING) call
-
- mRadioControl.triggerRing("18005551212");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_RINGING);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- ar = (AsyncResult) msg.obj;
- cn = (Connection) ar.result;
- assertTrue(cn.isRinging());
- assertEquals(mGSMPhone.getRingingCall(), cn.getCall());
-
- assertEquals(1, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.INCOMING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getRingingCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getRingingCall().getEarliestConnectTime());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- cn = mGSMPhone.getRingingCall().getConnections().get(0);
- assertTrue(cn.isIncoming());
- assertEquals(Connection.PostDialState.NOT_STARTED, cn.getPostDialState());
-
- assertFalse(mGSMPhone.canConference());
-
- // One mobile terminated active call
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getConnections().size() == 1);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE,
- mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertTrue(mGSMPhone.getForegroundCall().getEarliestConnectTime() > 0);
-
- cn = mGSMPhone.getForegroundCall().getConnections().get(0);
- assertTrue(cn.isIncoming());
- assertEquals(Connection.PostDialState.NOT_STARTED, cn.getPostDialState());
-
- assertFalse(mGSMPhone.canConference());
-
- // One disconnected (local hangup) call
-
- try {
- Connection conn;
- conn = mGSMPhone.getForegroundCall().getConnections().get(0);
- conn.hangup();
- } catch (CallStateException ex) {
- ex.printStackTrace();
- fail("unexpected ex");
- }
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED,
- mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertTrue(mGSMPhone.getForegroundCall().getEarliestConnectTime() > 0);
-
- cn = mGSMPhone.getForegroundCall().getEarliestConnection();
-
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- assertEquals(Connection.DisconnectCause.LOCAL, cn.getDisconnectCause());
-
- assertFalse(mGSMPhone.canConference());
-
- // Back to idle state
-
- mGSMPhone.clearDisconnected();
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(Connection.DisconnectCause.LOCAL, cn.getDisconnectCause());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- assertFalse(mGSMPhone.canConference());
-
- // cn left over from before phone.clearDisconnected();
-
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- // One ringing call
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getConnections().isEmpty());
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(1, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.INCOMING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getRingingCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getRingingCall().getEarliestConnectTime());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- assertFalse(mGSMPhone.canConference());
-
- // One rejected call
- mGSMPhone.rejectCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.IDLE);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(1, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getRingingCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getRingingCall().getEarliestConnectTime());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- cn = mGSMPhone.getRingingCall().getEarliestConnection();
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- assertEquals(Connection.DisconnectCause.INCOMING_MISSED, cn.getDisconnectCause());
-
- assertFalse(mGSMPhone.canConference());
-
- // Back to idle state
-
- mGSMPhone.clearDisconnected();
-
- assertEquals(Connection.DisconnectCause.INCOMING_MISSED, cn.getDisconnectCause());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(0, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestCreateTime());
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- assertFalse(mGSMPhone.canConference());
- assertEquals(Call.State.DISCONNECTED, cn.getState());
-
- // One ringing call
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getConnections().isEmpty());
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- cn = mGSMPhone.getRingingCall().getEarliestConnection();
-
- // Ringing call disconnects
-
- mRadioControl.triggerHangupForeground();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.IDLE);
-
- assertEquals(Connection.DisconnectCause.INCOMING_MISSED, cn.getDisconnectCause());
-
- // One Ringing Call
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.RINGING);
-
-
- cn = mGSMPhone.getRingingCall().getEarliestConnection();
-
- // One answered call
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // one holding call
- mGSMPhone.switchHoldingAndActive();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() == Call.State.IDLE);
-
-
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // one active call
- mGSMPhone.switchHoldingAndActive();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- }
- while (mGSMPhone.getBackgroundCall().getState() == Call.State.HOLDING);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // One disconnected call in the foreground slot
-
- mRadioControl.triggerHangupAll();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.IDLE);
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Connection.DisconnectCause.NORMAL, cn.getDisconnectCause());
-
- // Test missed calls
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.RINGING);
-
- mGSMPhone.rejectCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (msg.what != EVENT_DISCONNECT);
-
- ar = (AsyncResult) msg.obj;
- cn = (Connection) ar.result;
-
- assertEquals(Connection.DisconnectCause.INCOMING_MISSED, cn.getDisconnectCause());
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getRingingCall().getState());
-
- // Test incoming not missed calls
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.RINGING);
-
- cn = mGSMPhone.getRingingCall().getEarliestConnection();
-
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- assertEquals(Connection.DisconnectCause.NOT_DISCONNECTED, cn.getDisconnectCause());
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
-
- try {
- mGSMPhone.getForegroundCall().hangup();
- } catch (CallStateException ex) {
- ex.printStackTrace();
- fail("unexpected ex");
- }
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState()
- != Call.State.DISCONNECTED);
-
- assertEquals(Connection.DisconnectCause.LOCAL, cn.getDisconnectCause());
-
- //
- // Test held and hangup held calls
- //
-
- // One ALERTING call
- mGSMPhone.dial("+13125551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- assertTrue(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- mRadioControl.progressConnectingCallState();
- mRadioControl.progressConnectingCallState();
-
- // One ACTIVE call
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- // One ACTIVE call, one ringing call
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.RINGING);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- // One HOLDING call, one ACTIVE call
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertTrue(mGSMPhone.canConference());
-
- // Conference the two
- mGSMPhone.conference();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertTrue(mGSMPhone.getForegroundCall().isMultiparty());
- assertFalse(mGSMPhone.canConference());
-
- // Hold the multiparty call
- mGSMPhone.switchHoldingAndActive();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- }
- while (mGSMPhone.getBackgroundCall().getState() != Call.State.HOLDING);
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertTrue(mGSMPhone.getBackgroundCall().isMultiparty());
- assertFalse(mGSMPhone.canConference());
-
- // Multiparty call on hold, call waiting added
-
- mRadioControl.triggerRing("18005558355");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.RINGING);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertTrue(mGSMPhone.getBackgroundCall().isMultiparty());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertFalse(mGSMPhone.canConference());
-
- // Hangup conference call, ringing call still around
- mGSMPhone.getBackgroundCall().hangup();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.DISCONNECTED);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getBackgroundCall().getState());
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
-
- // Reject waiting call
- mGSMPhone.rejectCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.IDLE);
-
- assertFalse(mGSMPhone.getForegroundCall().isDialingOrAlerting());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
- }
-
- public void testOutgoingCallFailImmediately() throws Exception {
- Message msg;
-
- // Test outgoing call fail-immediately edge case
- // This happens when a call terminated before ever appearing in a
- // call list
- // This should land the immediately-failing call in the
- // ForegroundCall list as an IDLE call
- mRadioControl.setNextDialFailImmediately(true);
-
- Connection cn = mGSMPhone.dial("+13125551212");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Connection.DisconnectCause.NORMAL, cn.getDisconnectCause());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
- }
-
- public void testHangupOnOutgoing() throws Exception {
- Connection cn;
- Message msg;
-
- mRadioControl.setAutoProgressConnectingCall(false);
-
- // Test 1: local hangup in "DIALING" state
- mGSMPhone.dial("+13125551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- }
- while (mGSMPhone.getForegroundCall().getState() != Call.State.DIALING);
-
- cn = mGSMPhone.getForegroundCall().getEarliestConnection();
-
- mGSMPhone.getForegroundCall().hangup();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Connection.DisconnectCause.LOCAL, cn.getDisconnectCause());
-
- // Test 2: local hangup in "ALERTING" state
- mGSMPhone.dial("+13125551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- mRadioControl.progressConnectingCallState();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- }
- while (mGSMPhone.getForegroundCall().getState() != Call.State.ALERTING);
-
- cn = mGSMPhone.getForegroundCall().getEarliestConnection();
-
- mGSMPhone.getForegroundCall().hangup();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Connection.DisconnectCause.LOCAL, cn.getDisconnectCause());
-
- // Test 3: local immediate hangup before GSM index is
- // assigned (CallTracker.hangupPendingMO case)
-
- mRadioControl.pauseResponses();
-
- cn = mGSMPhone.dial("+13125551212");
-
- cn.hangup();
-
- mRadioControl.resumeResponses();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
-
- assertEquals(Connection.DisconnectCause.LOCAL,
- mGSMPhone.getForegroundCall().getEarliestConnection().getDisconnectCause());
- }
-
- public void testHangupOnChannelClose() throws Exception {
- mGSMPhone.dial("+13125551212");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getConnections().isEmpty());
-
- mRadioControl.shutdown();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- mGSMPhone.clearDisconnected();
- } while (!mGSMPhone.getForegroundCall().getConnections().isEmpty());
- }
-
- public void testIncallMmiCallDeflection() throws Exception {
- Message msg;
-
- // establish an active call
- mGSMPhone.dial("+13125551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // establish a ringing (WAITING) call
-
- mRadioControl.triggerRing("18005551212");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_RINGING);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering 0 followed by SEND: release all held calls
- // or sets UDUB for a waiting call.
- mGSMPhone.handleInCallMmiCommands("0");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getState() == Call.State.WAITING);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // change the active call to holding call
- mGSMPhone.switchHoldingAndActive();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() == Call.State.IDLE);
-
-
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering 0 followed by SEND: release all held calls
- // or sets UDUB for a waiting call.
- mGSMPhone.handleInCallMmiCommands("0");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() == Call.State.HOLDING);
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getBackgroundCall().getState());
- }
-
- public void testIncallMmiCallWaiting() throws Exception {
- Message msg;
-
- // establish an active call
- mGSMPhone.dial("+13125551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // establish a ringing (WAITING) call
-
- mRadioControl.triggerRing("18005551212");
-
- do {
- msg = mGSMTestHandler.waitForMessage(ANY_MESSAGE);
- assertNotNull("Message Time Out", msg);
- } while (msg.what != EVENT_RINGING);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering 1 followed by SEND: release all active calls
- // (if any exist) and accepts the other (held or waiting) call.
-
- mGSMPhone.handleInCallMmiCommands("1");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getState() == Call.State.WAITING);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
-
- // change the active call to holding call
- mGSMPhone.switchHoldingAndActive();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() == Call.State.IDLE);
-
- assertEquals(Call.State.IDLE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering 1 followed by SEND: release all active calls
- // (if any exist) and accepts the other (held or waiting) call.
- mGSMPhone.handleInCallMmiCommands("1");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
-
- // at this point, the active call with number==18005551212 should
- // have the gsm index of 2
-
- mRadioControl.triggerRing("16505550100");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_RINGING);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering "12" followed by SEND: release the call with
- // gsm index equals to 2.
- mGSMPhone.handleInCallMmiCommands("12");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() == Call.State.ACTIVE);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getState() != Phone.State.OFFHOOK);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertFalse(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // at this point, the call with number==16505550100 should
- // have the gsm index of 1
- mGSMPhone.dial("+13125551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE ||
- mGSMPhone.getBackgroundCall().getState() != Call.State.HOLDING);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // at this point, the active call with number==13125551212 should
- // have the gsm index of 2
-
- // Simulate entering "11" followed by SEND: release the call with
- // gsm index equals to 1. This should not be allowed, and a
- // Supplementary Service notification must be received.
- mGSMPhone.handleInCallMmiCommands("11");
-
- msg = mGSMTestHandler.waitForMessage(SUPP_SERVICE_FAILED);
- assertNotNull("Message Time Out", msg);
- assertFalse("IncallMmiCallWaiting: command should not work on holding call", msg == null);
-
- // Simulate entering "12" followed by SEND: release the call with
- // gsm index equals to 2.
- mGSMPhone.handleInCallMmiCommands("12");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() == Call.State.ACTIVE);
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // Simulate entering 1 followed by SEND: release all active calls
- // (if any exist) and accepts the other (held or waiting) call.
- mGSMPhone.handleInCallMmiCommands("1");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- assertEquals("16505550100",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
-
- // Simulate entering "11" followed by SEND: release the call with
- // gsm index equals to 1.
- mGSMPhone.handleInCallMmiCommands("11");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() == Call.State.ACTIVE);
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- }
-
- public void testIncallMmiCallHold() throws Exception {
- Message msg;
-
- // establish an active call
- mGSMPhone.dial("13125551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // establish a ringing (WAITING) call
-
- mRadioControl.triggerRing("18005551212");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_RINGING);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // simulate entering 2 followed by SEND: place all active calls
- // (if any exist) on hold and accepts the other (held or waiting)
- // call
-
- mGSMPhone.handleInCallMmiCommands("2");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getState() == Call.State.WAITING);
-
-
- assertFalse(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE,
- mGSMPhone.getForegroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertEquals("13125551212",
- mGSMPhone.getBackgroundCall().getConnections().get(0).getAddress());
-
- // swap the active and holding calls
- mGSMPhone.handleInCallMmiCommands("2");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_PHONE_STATE_CHANGED);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("13125551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getBackgroundCall().getConnections().get(0).getAddress());
-
- // merge the calls
- mGSMPhone.conference();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- assertEquals(2, mGSMPhone.getForegroundCall().getConnections().size());
-
- // at this point, we have an active conference call, with
- // call(1) = 13125551212 and call(2) = 18005551212
-
- // Simulate entering "23" followed by SEND: places all active call
- // on hold except call 3. This should fail and a supplementary service
- // failed notification should be received.
-
- mGSMPhone.handleInCallMmiCommands("23");
-
- msg = mGSMTestHandler.waitForMessage(SUPP_SERVICE_FAILED);
- assertNotNull("Message Time Out", msg);
- assertFalse("IncallMmiCallHold: separate should have failed!", msg == null);
-
- // Simulate entering "21" followed by SEND: places all active call
- // on hold except call 1.
- mGSMPhone.handleInCallMmiCommands("21");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() == Call.State.IDLE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("13125551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getBackgroundCall().getConnections().get(0).getAddress());
- }
-
- public void testIncallMmiMultipartyServices() throws Exception {
- // establish an active call
- mGSMPhone.dial("13125551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- // dial another call
- mGSMPhone.dial("18005551212");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- mGSMPhone.handleInCallMmiCommands("3");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertEquals(Phone.State.OFFHOOK, mGSMPhone.getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals("13125551212",
- mGSMPhone.getForegroundCall().getConnections().get(1).getAddress());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- }
-
- public void testCallIndex() throws Exception {
- Message msg;
-
- // establish the first call
- mGSMPhone.dial("16505550100");
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- String baseNumber = "1650555010";
-
- for (int i = 1; i < 6; i++) {
- String number = baseNumber + i;
-
- mGSMPhone.dial(number);
-
- do {
- mRadioControl.progressConnectingCallState();
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- if (mGSMPhone.getBackgroundCall().getConnections().size() >= 5) {
- break;
- }
-
- mGSMPhone.conference();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getBackgroundCall().getState() != Call.State.IDLE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- }
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("16505550105",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // create an incoming call, this call should have the call index
- // of 7
- mRadioControl.triggerRing("18005551212");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_RINGING);
- assertNotNull("Message Time Out", msg);
-
- assertEquals(Phone.State.RINGING, mGSMPhone.getState());
- assertTrue(mGSMPhone.getRingingCall().isRinging());
- assertEquals(Call.State.WAITING, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
-
- // hangup the background call and accept the ringing call
- mGSMPhone.getBackgroundCall().hangup();
- mGSMPhone.acceptCall();
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getRingingCall().getState() != Call.State.IDLE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals("18005551212",
- mGSMPhone.getForegroundCall().getConnections().get(0).getAddress());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertEquals("16505550105",
- mGSMPhone.getBackgroundCall().getConnections().get(0).getAddress());
-
- mGSMPhone.handleInCallMmiCommands("17");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() == Call.State.ACTIVE);
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.HOLDING, mGSMPhone.getBackgroundCall().getState());
- assertEquals("16505550105",
- mGSMPhone.getBackgroundCall().getConnections().get(0).
- getAddress());
-
- mGSMPhone.handleInCallMmiCommands("1");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() != Call.State.ACTIVE);
-
- assertEquals(Call.State.ACTIVE, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- mGSMPhone.handleInCallMmiCommands("16");
-
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (mGSMPhone.getForegroundCall().getState() == Call.State.ACTIVE);
-
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
- }
-
- public void testPostDialSequences() throws Exception {
- Message msg;
- AsyncResult ar;
- Connection cn;
-
- mGSMPhone.dial("+13125551212,1234;5N8xx");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(',', msg.arg1);
- assertEquals("1234;5N8", cn.getRemainingPostDialString());
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('1', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('2', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('3', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('4', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals(';', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(Connection.PostDialState.WAIT, cn.getPostDialState());
- assertEquals(Connection.PostDialState.WAIT, ar.userObj);
- cn.proceedAfterWaitChar();
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('5', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertEquals('N', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(Connection.PostDialState.WILD, cn.getPostDialState());
- assertEquals(Connection.PostDialState.WILD, ar.userObj);
- cn.proceedAfterWildChar(",6;7");
-
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(',', msg.arg1);
- assertEquals("6;78", cn.getRemainingPostDialString());
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('6', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals(';', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(Connection.PostDialState.WAIT, cn.getPostDialState());
- assertEquals(Connection.PostDialState.WAIT, ar.userObj);
- cn.proceedAfterWaitChar();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('7', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals('8', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- assertEquals(Connection.PostDialState.STARTED, ar.userObj);
-
- // Bogus chars at end should be ignored
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals(0, msg.arg1);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(Connection.PostDialState.COMPLETE,
- cn.getPostDialState());
- assertEquals(Connection.PostDialState.COMPLETE, ar.userObj);
- }
-
- public void testPostDialCancel() throws Exception {
- Message msg;
- AsyncResult ar;
- Connection cn;
-
- mGSMPhone.dial("+13125551212,N");
- mRadioControl.progressConnectingToActive();
-
- mRadioControl.progressConnectingToActive();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertNotNull("Message Time Out", msg);
- assertEquals(',', msg.arg1);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_POST_DIAL);
- assertEquals('N', msg.arg1);
- ar = (AsyncResult) (msg.obj);
- cn = (Connection) (ar.result);
- assertEquals(Connection.PostDialState.WILD, cn.getPostDialState());
- cn.cancelPostDial();
-
- assertEquals(Connection.PostDialState.CANCELLED, cn.getPostDialState());
- }
-
- public void testOutgoingCallFail() throws Exception {
- Message msg;
- /*
- * normal clearing
- */
-
- mRadioControl.setNextCallFailCause(CallFailCause.NORMAL_CLEARING);
- mRadioControl.setAutoProgressConnectingCall(false);
-
- Connection cn = mGSMPhone.dial("+13125551212");
-
- mRadioControl.progressConnectingCallState();
-
- // I'm just progressing the call state to
- // ensure getCurrentCalls() gets processed...
- // Normally these failure conditions would happen in DIALING
- // not ALERTING
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (cn.getState() == Call.State.DIALING);
-
-
- mRadioControl.triggerHangupAll();
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Connection.DisconnectCause.NORMAL, cn.getDisconnectCause());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- /*
- * busy
- */
-
- mRadioControl.setNextCallFailCause(CallFailCause.USER_BUSY);
- mRadioControl.setAutoProgressConnectingCall(false);
-
- cn = mGSMPhone.dial("+13125551212");
-
- mRadioControl.progressConnectingCallState();
-
- // I'm just progressing the call state to
- // ensure getCurrentCalls() gets processed...
- // Normally these failure conditions would happen in DIALING
- // not ALERTING
- do {
- assertNotNull("Message Time Out", mGSMTestHandler.waitForMessage(ANY_MESSAGE));
- } while (cn.getState() == Call.State.DIALING);
-
-
- mRadioControl.triggerHangupAll();
- msg = mGSMTestHandler.waitForMessage(EVENT_DISCONNECT);
- assertNotNull("Message Time Out", msg);
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Connection.DisconnectCause.BUSY, cn.getDisconnectCause());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED,
- mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
-
- /*
- * congestion
- */
-
- mRadioControl.setNextCallFailCause(CallFailCause.NO_CIRCUIT_AVAIL);
- mRadioControl.setAutoProgressConnectingCall(false);
-
- cn = mGSMPhone.dial("+13125551212");
-
- mRadioControl.progressConnectingCallState();
-
- // I'm just progressing the call state to
- // ensure getCurrentCalls() gets processed...
- // Normally these failure conditions would happen in DIALING
- // not ALERTING
- do {
- msg = mGSMTestHandler.waitForMessage(ANY_MESSAGE);
- assertNotNull("Message Time Out", msg);
- } while (cn.getState() == Call.State.DIALING);
-
-
- mRadioControl.triggerHangupAll();
-
- // Unlike the while loops above, this one waits
- // for a "phone state changed" message back to "idle"
- do {
- msg = mGSMTestHandler.waitForMessage(ANY_MESSAGE);
- assertNotNull("Message Time Out", msg);
- } while (!(msg.what == EVENT_PHONE_STATE_CHANGED
- && mGSMPhone.getState() == Phone.State.IDLE));
-
- assertEquals(Phone.State.IDLE, mGSMPhone.getState());
-
- assertEquals(Connection.DisconnectCause.CONGESTION, cn.getDisconnectCause());
-
- assertEquals(0, mGSMPhone.getRingingCall().getConnections().size());
- assertEquals(1, mGSMPhone.getForegroundCall().getConnections().size());
- assertEquals(0, mGSMPhone.getBackgroundCall().getConnections().size());
-
- assertEquals(Call.State.IDLE, mGSMPhone.getRingingCall().getState());
- assertEquals(Call.State.DISCONNECTED, mGSMPhone.getForegroundCall().getState());
- assertEquals(Call.State.IDLE, mGSMPhone.getBackgroundCall().getState());
-
- assertTrue(mGSMPhone.getForegroundCall().getEarliestCreateTime() > 0);
- assertEquals(0, mGSMPhone.getForegroundCall().getEarliestConnectTime());
- }
-
- public void testSSNotification() throws Exception {
- // MO
- runTest(0, SuppServiceNotification.MO_CODE_UNCONDITIONAL_CF_ACTIVE);
- runTest(0, SuppServiceNotification.MO_CODE_CALL_IS_WAITING);
- runTest(0, SuppServiceNotification.MO_CODE_CALL_DEFLECTED);
-
- // MT
- runTest(1, SuppServiceNotification.MT_CODE_FORWARDED_CALL);
- runTest(1, SuppServiceNotification.MT_CODE_CALL_CONNECTED_ECT);
- runTest(1, SuppServiceNotification.MT_CODE_ADDITIONAL_CALL_FORWARDED);
- }
-
- private void runTest(int type, int code) {
- Message msg;
-
- mRadioControl.triggerSsn(type, code);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_SSN);
- assertNotNull("Message Time Out", msg);
- AsyncResult ar = (AsyncResult) msg.obj;
-
- assertNull(ar.exception);
-
- SuppServiceNotification notification =
- (SuppServiceNotification) ar.result;
-
- assertEquals(type, notification.notificationType);
- assertEquals(code, notification.code);
- }
-
- public void testUssd() throws Exception {
- // Quick hack to work around a race condition in this test:
- // We may initiate a USSD MMI before GSMPhone receives its initial
- // GSMTestHandler.EVENT_RADIO_OFF_OR_NOT_AVAILABLE event. When the phone sees this
- // event, it will cancel the just issued USSD MMI, which we don't
- // want. So sleep a little first.
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- // do nothing
- }
-
- verifyNormal();
- verifyCancel();
- varifyNetworkInitiated();
- }
-
- private void varifyNetworkInitiated() {
- Message msg;
- AsyncResult ar;
- MmiCode mmi;
-
- // Receive an incoming NOTIFY
- mRadioControl.triggerIncomingUssd("0", "NOTIFY message");
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertFalse(mmi.isUssdRequest());
-
- // Receive a REQUEST and send response
- mRadioControl.triggerIncomingUssd("1", "REQUEST Message");
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertTrue(mmi.isUssdRequest());
-
- mGSMPhone.sendUssdResponse("## TEST: TEST_GSMPhone responding...");
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_INITIATE);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- GsmMmiCode gsmMmi = (GsmMmiCode) mmi;
- assertTrue(gsmMmi.isPendingUSSD());
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertNull(ar.exception);
- assertFalse(mmi.isUssdRequest());
-
- // Receive a REQUEST and cancel
- mRadioControl.triggerIncomingUssd("1", "REQUEST Message");
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertTrue(mmi.isUssdRequest());
-
- mmi.cancel();
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
-
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertNull(ar.exception);
- assertEquals(MmiCode.State.CANCELLED, mmi.getState());
-
- List mmiList = mGSMPhone.getPendingMmiCodes();
- assertEquals(0, mmiList.size());
- }
-
- private void verifyNormal() throws CallStateException {
- Message msg;
- AsyncResult ar;
- MmiCode mmi;
-
- mGSMPhone.dial("#646#");
-
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_INITIATE);
- assertNotNull("Message Time Out", msg);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
-
- ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
- assertEquals(MmiCode.State.COMPLETE, mmi.getState());
- }
-
-
- private void verifyCancel() throws CallStateException {
- /**
- * This case makes an assumption that dial() will add the USSD
- * to the "pending MMI codes" list before it returns. This seems
- * like reasonable semantics. It also assumes that the USSD
- * request in question won't complete until we get back to the
- * event loop, thus cancel() is safe.
- */
- Message msg;
-
- mGSMPhone.dial("#646#");
-
- List<? extends MmiCode> pendingMmis = mGSMPhone.getPendingMmiCodes();
-
- assertEquals(1, pendingMmis.size());
-
- MmiCode mmi = pendingMmis.get(0);
- assertTrue(mmi.isCancelable());
- mmi.cancel();
-
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_INITIATE);
- assertNotNull("Message Time Out", msg);
-
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
-
- AsyncResult ar = (AsyncResult) msg.obj;
- mmi = (MmiCode) ar.result;
-
- assertEquals(MmiCode.State.CANCELLED, mmi.getState());
- }
-
- public void testRilHooks() throws Exception {
- //
- // These test cases all assume the RIL OEM hooks
- // just echo back their input
- //
-
- Message msg;
- AsyncResult ar;
-
- // null byte array
-
- mGSMPhone.invokeOemRilRequestRaw(null, mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertNull(ar.result);
- assertNull(ar.exception);
-
- // empty byte array
-
- mGSMPhone.invokeOemRilRequestRaw(new byte[0], mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertEquals(0, ((byte[]) (ar.result)).length);
- assertNull(ar.exception);
-
- // byte array with data
-
- mGSMPhone.invokeOemRilRequestRaw("Hello".getBytes("utf-8"),
- mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertEquals("Hello", new String(((byte[]) (ar.result)), "utf-8"));
- assertNull(ar.exception);
-
- // null strings
-
- mGSMPhone.invokeOemRilRequestStrings(null, mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertNull(ar.result);
- assertNull(ar.exception);
-
- // empty byte array
-
- mGSMPhone.invokeOemRilRequestStrings(new String[0],
- mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertEquals(0, ((String[]) (ar.result)).length);
- assertNull(ar.exception);
-
- // Strings with data
-
- String s[] = new String[1];
-
- s[0] = "Hello";
-
- mGSMPhone.invokeOemRilRequestStrings(s, mHandler.obtainMessage(EVENT_OEM_RIL_MESSAGE));
-
- msg = mGSMTestHandler.waitForMessage(EVENT_OEM_RIL_MESSAGE);
- assertNotNull("Message Time Out", msg);
-
- ar = ((AsyncResult) msg.obj);
-
- assertEquals("Hello", ((String[]) (ar.result))[0]);
- assertEquals(1, ((String[]) (ar.result)).length);
- assertNull(ar.exception);
- }
-
- public void testMmi() throws Exception {
- mRadioControl.setAutoProgressConnectingCall(false);
-
- // "valid" MMI sequences
- runValidMmi("*#67#", false);
- runValidMmi("##43*11#", false);
- runValidMmi("#33*1234*11#", false);
- runValidMmi("*21*6505551234**5#", false);
- runValidMmi("**03**1234*4321*4321#", false);
- // pound string
- runValidMmi("5308234092307540923#", true);
- // short code
- runValidMmi("22", true);
- // as part of call setup
- runValidMmiWithConnect("*31#6505551234");
-
- // invalid MMI sequences
- runNotMmi("6505551234");
- runNotMmi("1234#*12#34566654");
- runNotMmi("*#*#12#*");
- }
-
- private void runValidMmi(String dialString, boolean cancelable) throws CallStateException {
- Connection c = mGSMPhone.dial(dialString);
- assertNull(c);
- Message msg = mGSMTestHandler.waitForMessage(EVENT_MMI_INITIATE);
- assertNotNull("Message Time Out", msg);
- // Should not be cancelable.
- AsyncResult ar = (AsyncResult) msg.obj;
- MmiCode mmi = (MmiCode) ar.result;
- assertEquals(cancelable, mmi.isCancelable());
-
- msg = mGSMTestHandler.waitForMessage(EVENT_MMI_COMPLETE);
- assertNotNull("Message Time Out", msg);
- }
-
- private void runValidMmiWithConnect(String dialString) throws CallStateException {
- mRadioControl.pauseResponses();
-
- Connection c = mGSMPhone.dial(dialString);
- assertNotNull(c);
-
- hangup(c);
- }
-
- private void hangup(Connection cn) throws CallStateException {
- cn.hangup();
-
- mRadioControl.resumeResponses();
- assertNotNull(mGSMTestHandler.waitForMessage(EVENT_DISCONNECT));
-
- }
-
- private void runNotMmi(String dialString) throws CallStateException {
- mRadioControl.pauseResponses();
-
- Connection c = mGSMPhone.dial(dialString);
- assertNotNull(c);
-
- hangup(c);
- }
-}
diff --git a/tests/CoreTests/com/android/internal/telephony/gsm/GSMTestHandler.java b/tests/CoreTests/com/android/internal/telephony/gsm/GSMTestHandler.java
deleted file mode 100644
index fb8a5d9..0000000
--- a/tests/CoreTests/com/android/internal/telephony/gsm/GSMTestHandler.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2009 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.internal.telephony.gsm;
-
-import android.content.Context;
-
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.internal.telephony.gsm.GSMPhone;
-import com.android.internal.telephony.test.SimulatedCommands;
-import com.android.internal.telephony.TestPhoneNotifier;
-
-/**
- * This class creates a HandlerThread which waits for the various messages.
- */
-public class GSMTestHandler extends HandlerThread implements Handler.Callback {
-
- private Handler mHandler;
- private Message mCurrentMessage;
-
- private Boolean mMsgConsumed;
- private SimulatedCommands sc;
- private GSMPhone mGSMPhone;
- private Context mContext;
-
- private static final int FAIL_TIMEOUT_MILLIS = 5 * 1000;
-
- public GSMTestHandler(Context context) {
- super("GSMPhoneTest");
- mMsgConsumed = false;
- mContext = context;
- }
-
- @Override
- protected void onLooperPrepared() {
- sc = new SimulatedCommands();
- mGSMPhone = new GSMPhone(mContext, sc, new TestPhoneNotifier(), true);
- mHandler = new Handler(getLooper(), this);
- synchronized (this) {
- notifyAll();
- }
- }
-
- public boolean handleMessage(Message msg) {
- synchronized (this) {
- mCurrentMessage = msg;
- this.notifyAll();
- while(!mMsgConsumed) {
- try {
- this.wait();
- } catch (InterruptedException e) {}
- }
- mMsgConsumed = false;
- }
- return true;
- }
-
-
- public void cleanup() {
- Looper looper = getLooper();
- if (looper != null) looper.quit();
- mHandler = null;
- }
-
- public Handler getHandler() {
- return mHandler;
- }
-
- public SimulatedCommands getSimulatedCommands() {
- return sc;
- }
-
- public GSMPhone getGSMPhone() {
- return mGSMPhone;
- }
-
- public Message waitForMessage(int code) {
- Message msg;
- while(true) {
- msg = null;
- synchronized (this) {
- try {
- this.wait(FAIL_TIMEOUT_MILLIS);
- } catch (InterruptedException e) {
- }
-
- // Check if timeout has occurred.
- if (mCurrentMessage != null) {
- // Consume the message
- msg = Message.obtain();
- msg.copyFrom(mCurrentMessage);
- mCurrentMessage = null;
- mMsgConsumed = true;
- this.notifyAll();
- }
- }
- if (msg == null || code == GSMPhoneTest.ANY_MESSAGE || msg.what == code) return msg;
- }
- }
-}
diff --git a/tests/CoreTests/com/android/internal/util/PredicatesTest.java b/tests/CoreTests/com/android/internal/util/PredicatesTest.java
deleted file mode 100644
index c46ff05..0000000
--- a/tests/CoreTests/com/android/internal/util/PredicatesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008 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.internal.util;
-
-import junit.framework.TestCase;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-public class PredicatesTest extends TestCase {
-
- private static final Predicate<Object> TRUE = new Predicate<Object>() {
- public boolean apply(Object o) {
- return true;
- }
- };
-
- private static final Predicate<Object> FALSE = new Predicate<Object>() {
- public boolean apply(Object o) {
- return false;
- }
- };
-
- public void testAndPredicate_AllConditionsTrue() throws Exception {
- assertTrue(Predicates.and(newArrayList(TRUE)).apply(null));
- assertTrue(Predicates.and(newArrayList(TRUE, TRUE)).apply(null));
- }
-
- public void testAndPredicate_AtLeastOneConditionIsFalse() throws Exception {
- assertFalse(Predicates.and(newArrayList(FALSE, TRUE, TRUE)).apply(null));
- assertFalse(Predicates.and(newArrayList(TRUE, FALSE, TRUE)).apply(null));
- assertFalse(Predicates.and(newArrayList(TRUE, TRUE, FALSE)).apply(null));
- }
-
- public void testOrPredicate_AllConditionsTrue() throws Exception {
- assertTrue(Predicates.or(newArrayList(TRUE, TRUE, TRUE)).apply(null));
- }
-
- public void testOrPredicate_AllConditionsFalse() throws Exception {
- assertFalse(Predicates.or(newArrayList(FALSE, FALSE, FALSE)).apply(null));
- }
-
- public void testOrPredicate_AtLeastOneConditionIsTrue() throws Exception {
- assertTrue(Predicates.or(newArrayList(TRUE, FALSE, FALSE)).apply(null));
- assertTrue(Predicates.or(newArrayList(FALSE, TRUE, FALSE)).apply(null));
- assertTrue(Predicates.or(newArrayList(FALSE, FALSE, TRUE)).apply(null));
- }
-
- public void testNotPredicate() throws Exception {
- assertTrue(Predicates.not(FALSE).apply(null));
- assertFalse(Predicates.not(TRUE).apply(null));
- }
-
- private static <E> ArrayList<E> newArrayList(E... elements) {
- ArrayList<E> list = new ArrayList<E>();
- Collections.addAll(list, elements);
- return list;
- }
-
-}