View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.test.model;
17  
18  import org.fourthline.cling.model.meta.DeviceDetails;
19  import org.fourthline.cling.model.meta.Icon;
20  import org.fourthline.cling.model.meta.RemoteDevice;
21  import org.fourthline.cling.model.meta.RemoteService;
22  import org.fourthline.cling.model.types.UDADeviceType;
23  import org.fourthline.cling.test.data.SampleData;
24  import org.testng.annotations.Test;
25  
26  import java.net.URI;
27  
28  import static org.testng.Assert.*;
29  
30  /**
31   * @author Christian Bauer
32   */
33  public class IconTest {
34  
35      @Test
36      public void validIcons() throws Exception {
37          RemoteDevice rd = new RemoteDevice(
38              SampleData.createRemoteDeviceIdentity(),
39              new UDADeviceType("Foo", 1),
40              new DeviceDetails("Foo"),
41              new Icon[]{
42                  new Icon(null, 0, 0, 0, URI.create("foo")),
43                  new Icon("foo/bar", 0, 0, 0, URI.create("foo")),
44                  new Icon("foo/bar", 123, 456, 0, URI.create("foo"))
45              },
46              new RemoteService[0]
47          );
48          assertEquals(rd.findIcons().length, 3);
49      }
50  
51      @Test
52      public void invalidIcons() throws Exception {
53          RemoteDevice rd = new RemoteDevice(
54              SampleData.createRemoteDeviceIdentity(),
55              new UDADeviceType("Foo", 1),
56              new DeviceDetails("Foo"),
57              new Icon[]{
58                  new Icon("image/png", 123, 123, 8, URI.create("urn:not_a_URL")),
59              },
60              new RemoteService[0]
61          );
62          assertEquals(rd.findIcons().length, 0);
63      }
64  }