1package com.xtremelabs.robolectric.shadows;
2
3import android.net.wifi.ScanResult;
4import com.xtremelabs.robolectric.Robolectric;
5import com.xtremelabs.robolectric.internal.Implementation;
6import com.xtremelabs.robolectric.internal.Implements;
7import com.xtremelabs.robolectric.internal.RealObject;
8
9@Implements(ScanResult.class)
10public class ShadowScanResult {
11
12    @RealObject ScanResult realObject;
13
14    public static ScanResult newInstance(String SSID, String BSSID, String caps, int level, int frequency) {
15        ScanResult scanResult = Robolectric.newInstanceOf(ScanResult.class);
16        scanResult.SSID = SSID;
17        scanResult.BSSID = BSSID;
18        scanResult.capabilities = caps;
19        scanResult.level = level;
20        scanResult.frequency = frequency;
21        return scanResult;
22    }
23
24    @Override @Implementation
25    public String toString() {
26        return new StringBuffer()
27                .append("SSID: ").append(valueOrNone(realObject.SSID))
28                .append(", BSSID: ").append(valueOrNone(realObject.BSSID))
29                .append(", capabilities: ").append(valueOrNone(realObject.capabilities))
30                .append(", level: ").append(realObject.level)
31                .append(", frequency: ").append(realObject.frequency)
32                .toString();
33    }
34
35    private String valueOrNone(String value) {
36        return value == null ? "<none>" : value;
37    }
38}
39
40