01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device;
18:
19: import junit.framework.TestCase;
20: import org.compass.gps.impl.SingleCompassGps;
21:
22: /**
23: *
24: * @author kimchy
25: *
26: */
27: public class ScheduledMirrorGpsDeviceTests extends TestCase {
28:
29: public void testScheduleDevice() throws Exception {
30: SingleCompassGps gps = new SingleCompassGps();
31:
32: MockActiveMirrorGpsDevice mockDevice = new MockActiveMirrorGpsDevice();
33: mockDevice.setName("mockDevice");
34: mockDevice.clear();
35: ScheduledMirrorGpsDevice scheduledDevice = new ScheduledMirrorGpsDevice(
36: mockDevice);
37: scheduledDevice.setPeriod(50);
38:
39: gps.addGpsDevice(scheduledDevice);
40:
41: scheduledDevice.start();
42:
43: try {
44: Thread.sleep(500);
45: } catch (InterruptedException e) {
46: }
47: assertTrue(mockDevice.isPerformMirroringCalled());
48:
49: scheduledDevice.stop();
50: try {
51: Thread.sleep(100);
52: } catch (InterruptedException e) {
53: }
54: mockDevice.clear();
55: try {
56: Thread.sleep(500);
57: } catch (InterruptedException e) {
58: }
59: assertFalse(mockDevice.isPerformMirroringCalled());
60:
61: }
62: }
|