summaryrefslogtreecommitdiffstats
path: root/tests/framework-tests
diff options
context:
space:
mode:
authorDan Egnor <egnor@google.com>2010-01-06 23:12:57 -0800
committerDan Egnor <egnor@google.com>2010-01-07 00:28:58 -0800
commit6916089e838662b41d902cd9a0d2560b04633ef9 (patch)
tree8ec507232b223c4362c816bb0ba6c8543f136759 /tests/framework-tests
parent4cd9f5454aa51a284e6cc70ecc932cb6213b5f10 (diff)
downloadframeworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.zip
frameworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.tar.gz
frameworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.tar.bz2
Remove old EventLog tests from here, they will be replaced by a
(better) EventLog test in CTS. Fix some minor errors in the handling of too-large event log values.
Diffstat (limited to 'tests/framework-tests')
-rw-r--r--tests/framework-tests/src/android/test/FrameworkTests.java4
-rw-r--r--tests/framework-tests/src/android/util/EventLogFunctionalTest.java143
-rw-r--r--tests/framework-tests/src/android/util/EventLogTest.java68
3 files changed, 0 insertions, 215 deletions
diff --git a/tests/framework-tests/src/android/test/FrameworkTests.java b/tests/framework-tests/src/android/test/FrameworkTests.java
index b5f6292..623e294 100644
--- a/tests/framework-tests/src/android/test/FrameworkTests.java
+++ b/tests/framework-tests/src/android/test/FrameworkTests.java
@@ -1,8 +1,6 @@
package android.test;
import com.android.internal.os.LoggingPrintStreamTest;
-import android.util.EventLogFunctionalTest;
-import android.util.EventLogTest;
import junit.framework.TestSuite;
import com.android.internal.http.multipart.MultipartTest;
import com.android.internal.policy.impl.LockPatternKeyguardViewTest;
@@ -18,8 +16,6 @@ public class FrameworkTests {
TestSuite suite = new TestSuite(FrameworkTests.class.getName());
suite.addTestSuite(MultipartTest.class);
- suite.addTestSuite(EventLogTest.class);
- suite.addTestSuite(EventLogFunctionalTest.class);
suite.addTestSuite(LoggingPrintStreamTest.class);
suite.addTestSuite(LockPatternKeyguardViewTest.class);
diff --git a/tests/framework-tests/src/android/util/EventLogFunctionalTest.java b/tests/framework-tests/src/android/util/EventLogFunctionalTest.java
deleted file mode 100644
index 8afe35f..0000000
--- a/tests/framework-tests/src/android/util/EventLogFunctionalTest.java
+++ /dev/null
@@ -1,143 +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 android.os.Process;
-
-import com.google.android.collect.Lists;
-
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
-import java.util.ArrayList;
-
-/**
- * Functional tests of EventLog.
- */
-
-public class EventLogFunctionalTest extends TestCase {
- private static final String TAG = "EventLogFunctionalTest";
-
- private static final int TAG_SIZE = 4;
- private static final int TYPE_FIELD_SIZE = 1;
- private static final int STARTING_POS_OF_PAYLOAD = TAG_SIZE + TYPE_FIELD_SIZE;
-
- private static final int TEST_TAG = 42;
- private static final int TEST_TAG2 = 314;
-
- //todo: For now all we do is test the returned length. More to come.
- public void testLogOfPosInt() throws Exception {
- final int numBytes = EventLog.writeEvent(TEST_TAG, 0x01020304);
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 4, numBytes);
- }
-
- //todo: For now all we do is test the returned length. More to come.
- public void testLogOfPosLong() throws Exception {
- final int numBytes = EventLog.writeEvent(TEST_TAG2, 0x0102030405060708L);
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 8, numBytes);
- }
-
- //todo: For now all we do is test the returned length. More to come.
- public void testLogOfString() throws Exception {
- final String valueStr = "foo bar baz";
- final int numBytes = EventLog.writeEvent(TEST_TAG, valueStr);
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 4 + valueStr.length() + 1, numBytes);
- }
-
- public void testLogOfListWithOneInt() throws Exception {
- final int numBytes = EventLog.writeEvent(TEST_TAG, new Object[] {1234});
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + 1 + 4 + 1, numBytes);
- }
-
- public void testLogOfListWithMultipleInts() throws Exception {
- final int numBytes = EventLog.writeEvent(TEST_TAG, new Object[] {1234, 2345, 3456});
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + 1 + 4 + 1 + 4 + 1 + 4 + 1, numBytes);
- }
-
- public void testEventLargerThanInitialBufferCapacity() throws Exception {
- final Integer[] array = new Integer[127];
- for (int i = 0; i < array.length; i++) {
- array[i] = i;
- }
- final int numBytes = EventLog.writeEvent(TEST_TAG, (Object[]) array);
- Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + (5 * array.length) + 1, numBytes);
- }
-
- // This test is obsolete. See http://b/issue?id=1262082
- public void disableTestReadSimpleEvent() throws Exception {
- long when = System.currentTimeMillis();
- EventLog.writeEvent(2718, 12345);
- Log.i(TAG, "Wrote simple event at T=" + when);
-
- ArrayList<EventLog.Event> list = new ArrayList<EventLog.Event>();
- EventLog.readEvents(new int[] { 2718 }, list);
-
- boolean found = false;
- for (EventLog.Event event : list) {
- assertEquals(event.getTag(), 2718);
- long eventTime = event.getTimeNanos() / 1000000;
- Log.i(TAG, " Found event T=" + eventTime);
- if (eventTime > when - 100 && eventTime < when + 1000) {
- assertEquals(event.getProcessId(), Process.myPid());
- assertEquals(event.getThreadId(), Process.myTid());
- assertEquals(event.getData(), 12345);
-
- assertFalse(found);
- found = true;
- }
- }
-
- assertTrue(found);
- }
-
- // This test is obsolete. See http://b/issue?id=1262082
- public void disableTestReadCompoundEntry() throws Exception {
- long when = System.currentTimeMillis();
- EventLog.writeEvent(2719, 1l, "2", 3);
- Log.i(TAG, "Wrote compound event at T=" + when);
-
- ArrayList<EventLog.Event> list = new ArrayList<EventLog.Event>();
- EventLog.readEvents(new int[] { 2719 }, list);
-
- boolean found = false;
- for (EventLog.Event event : list) {
- long eventTime = event.getTimeNanos() / 1000000;
- Log.i(TAG, " Found event T=" + eventTime);
- if (eventTime > when - 100 && eventTime < when + 1000) {
- Object[] data = (Object[]) event.getData();
- assertEquals(data.length, 3);
- assertEquals(data[0], 1l);
- assertEquals(data[1], "2");
- assertEquals(data[2], 3);
- assertFalse(found);
- found = true;
- }
- }
-
- assertTrue(found);
- }
-
- public void testEventLogTagsFile() throws Exception {
- EventLogTags tags = new EventLogTags();
- assertEquals(tags.get("answer").mTag, 42);
- assertEquals(tags.get("pi").mTag, 314);
- assertEquals(tags.get("e").mTag, 2718);
- assertEquals(tags.get(42).mName, "answer");
- assertEquals(tags.get(314).mName, "pi");
- assertEquals(tags.get(2718).mName, "e");
- }
-}
diff --git a/tests/framework-tests/src/android/util/EventLogTest.java b/tests/framework-tests/src/android/util/EventLogTest.java
deleted file mode 100644
index 2a9e9cd..0000000
--- a/tests/framework-tests/src/android/util/EventLogTest.java
+++ /dev/null
@@ -1,68 +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 com.google.android.collect.Lists;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * tests for {@link EventLog}
- */
-
-public class EventLogTest extends TestCase {
- private static final int TEST_TAG = 42;
-
- public void testIllegalListTypesThrowException() throws Exception {
- try {
- EventLog.writeEvent(TEST_TAG, new Object[]{new Object()});
- fail("Can't create List with any old Object");
- } catch (IllegalArgumentException e) {
- // expected
- }
- try {
- EventLog.writeEvent(TEST_TAG, new Object[]{(byte) 1});
- fail("Can't create List with any old byte");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- void assertIntInByteArrayEquals(int expected, byte[] buf, int pos) {
- ByteBuffer computedBuf = ByteBuffer.wrap(buf).order(ByteOrder.nativeOrder());
- int computed = computedBuf.getInt(pos);
- Assert.assertEquals(expected, computed);
- }
-
- void assertLongInByteArrayEquals(long expected, byte[] buf, int pos) {
- ByteBuffer computedBuf = ByteBuffer.wrap(buf).order(ByteOrder.nativeOrder());
- long computed = computedBuf.getLong(pos);
- Assert.assertEquals(expected, computed);
- }
-
- void assertStringInByteArrayEquals(String expected, byte[] buf, int pos) {
- byte[] expectedBytes = expected.getBytes();
- Assert.assertTrue(expectedBytes.length <= buf.length - pos);
- for (byte expectedByte : expectedBytes) {
- Assert.assertEquals(expectedByte, buf[pos++]);
- }
- }
-}