My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.bluecove.emu.gui.model;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import junit.framework.TestCase;

import com.intel.bluetooth.emu.MonitorDevice;

/**
*
*
*/
public class ModelUpdateTest extends TestCase implements Observer {

private Model model;

protected void setUp() throws Exception {
super.setUp();
try {
model = Model.instance();
model.addObserver(this);
} catch (Exception e) {
}
}

public void testUpdateDeviceList() throws IOException {
List<MonitorDevice> newDevices1 = new ArrayList<MonitorDevice>();
newDevices1.add(new MonitorDeviceMock(22, "22-1", 1));
newDevices1.add(new MonitorDeviceMock(23, "23-1", 1));
newDevices1.add(new MonitorDeviceMock(24, "24-1", 1));
newDevices1.add(new MonitorDeviceMock(25, "25-1", 1));

model.updateDeviceList(newDevices1);
assertEquals(4, newDevices1.size());

List<MonitorDevice> newDevices2 = new ArrayList<MonitorDevice>();
newDevices2.add(new MonitorDeviceMock(32, "32-2", 1));
newDevices2.add(new MonitorDeviceMock(23, "23-2", 1));
newDevices2.add(new MonitorDeviceMock(24, "24-2", 1));
newDevices2.add(new MonitorDeviceMock(35, "35-2", 1));
model.updateDeviceList(newDevices2);
assertEquals(4, newDevices2.size());
// This is invalid tests since it depends on order in HashMap
// assertEquals("23-2",
// model.devices.get(0).getMonitorDevice().getDeviceDescriptor().getName());
// assertEquals("24-2",
// model.devices.get(1).getMonitorDevice().getDeviceDescriptor().getName());
// assertEquals("32-2",
// model.devices.get(2).getMonitorDevice().getDeviceDescriptor().getName());
// assertEquals("35-2",
// model.devices.get(3).getMonitorDevice().getDeviceDescriptor().getName());

}

public void update(Observable o, Object arg) {
System.out.println(arg);
}

}

Change log

r2476 by skarzhevskyy on Dec 1, 2008   Diff
Correction to headers
Go to: 
Project members, sign in to write a code review

Older revisions

r2415 by skarzhevskyy on Oct 9, 2008   Diff
remove invalid tests since it depends
on order in HashMap
r2408 by skarzhevskyy on Oct 9, 2008   Diff
organize product to modules
r1940 by Michael.Lifschitz on Mar 24, 2008   Diff
added model
All revisions of this file

File info

Size: 1896 bytes, 63 lines

File properties

svn:mime-type
text/plain
svn:eol-style
native
svn:keywords
Date Author Id Revision
Powered by Google Project Hosting