01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.awt.tests.nativebridge;
19:
20: import junit.framework.TestCase;
21: import org.apache.harmony.awt.nativebridge.NativeBridge;
22: import org.apache.harmony.awt.nativebridge.PointerPointer;
23: import org.apache.harmony.awt.nativebridge.ByteBase;
24:
25: public class PointerPointerTest extends TestCase {
26: private PointerPointer p;
27: private PointerPointer p1;
28:
29: // Regression tests for HARMONY-2547
30: @Override
31: protected void setUp() throws Exception {
32: super .setUp();
33: p = NativeBridge.getInstance().createPointerPointer(2, false);
34: p.setAddress(1, 0xFFFFFFFFL);
35: p1 = NativeBridge.getInstance().createPointerPointer(2, false);
36: p1.setAddress(0, 0xFFFFFFFFL);
37: }
38:
39: public void test_get() {
40: assertNull("*p != 0", p.get(0));
41: assertNull("*(p+1) != 0", p1.get(1));
42: }
43:
44: public void test_getAddress() {
45: assertEquals("*p != 0", 0, p.getAddress(0));
46: assertEquals("*(p+1) != 0", 0, p1.getAddress(1));
47: }
48:
49: public void test_set() {
50: byte dst[] = new byte[8];
51:
52: p.set(1, NativeBridge.getInstance().createInt32Pointer(
53: 0x04030201L));
54: p.byteBase.get(dst, 0, ByteBase.POINTER_SIZE * 2);
55:
56: for (int i = ByteBase.POINTER_SIZE; i < ByteBase.POINTER_SIZE + 4; i++) {
57: assertEquals(i - ByteBase.POINTER_SIZE + 1, dst[i]);
58: }
59: }
60:
61: public void test_setAddress() {
62: byte dst[] = new byte[8];
63:
64: p.setAddress(1, 0x04030201L);
65: p.byteBase.get(dst, 0, ByteBase.POINTER_SIZE * 2);
66:
67: for (int i = ByteBase.POINTER_SIZE; i < ByteBase.POINTER_SIZE + 4; i++) {
68: assertEquals(i - ByteBase.POINTER_SIZE + 1, dst[i]);
69: }
70: }
71:
72: }
|