View Javadoc

1   /***
2    *     Ambient - A music player for the Android platform
3    Copyright (C) 2007 Martin Vysny
4    
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9    
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14  
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package sk.baka.ambient.collection;
20  
21  import junit.framework.TestCase;
22  
23  /***
24   * Tests {@link TrackMetadataBean}.
25   * 
26   * @author Martin Vysny
27   */
28  public class TrackMetadataBeanTest extends TestCase {
29  	/***
30  	 */
31  	public void testFailures() {
32  		try {
33  			new TrackMetadataBean.Builder().build(-1);
34  			fail();
35  		} catch (IllegalArgumentException ex) {
36  			// okay
37  		}
38  		try {
39  			new TrackMetadataBean.Builder().setLocation("/").build(-1);
40  			fail();
41  		} catch (IllegalArgumentException ex) {
42  			// okay
43  		}
44  		try {
45  			new TrackMetadataBean.Builder().setOrigin(TrackOriginEnum.Ampache)
46  					.build(-1);
47  			fail();
48  		} catch (IllegalArgumentException ex) {
49  			// okay
50  		}
51  	}
52  
53  	/***
54  	 */
55  	public void testDisplayableName() {
56  		TrackMetadataBean t = new TrackMetadataBean.Builder().setOrigin(
57  				TrackOriginEnum.Ampache).setLocation("http://blabla").build(-1);
58  		assertEquals("http://blabla", t.getDisplayableName());
59  		t = new TrackMetadataBean.Builder().setOrigin(TrackOriginEnum.LocalFs)
60  				.setLocation("/foo/bar/baz").build(-1);
61  		assertEquals("baz", t.getDisplayableName());
62  		t = new TrackMetadataBean.Builder().setOrigin(TrackOriginEnum.LocalFs)
63  				.setLocation("/foo/bar/baz").setTitle("BAZ").build(-1);
64  		assertEquals("BAZ", t.getDisplayableName());
65  	}
66  }