|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.s60tools.imaker.internal.tests; |
|
18 |
|
19 import static org.easymock.EasyMock.*; |
|
20 |
|
21 |
|
22 import java.util.ArrayList; |
|
23 import java.util.List; |
|
24 |
|
25 import junit.framework.TestCase; |
|
26 |
|
27 import org.eclipse.core.runtime.IProgressMonitor; |
|
28 |
|
29 import com.nokia.s60tools.imaker.IEnvironment; |
|
30 import com.nokia.s60tools.imaker.IIMakerWrapper; |
|
31 import com.nokia.s60tools.imaker.UIConfiguration; |
|
32 import com.nokia.s60tools.imaker.internal.iqrf.IQRFFactory; |
|
33 import com.nokia.s60tools.imaker.internal.model.Environment; |
|
34 |
|
35 public class EnvironmentTest extends TestCase { |
|
36 private IEnvironment environment = null; |
|
37 private IIMakerWrapper wrapperMock = null; |
|
38 private static final String DRIVE = "x:\\"; |
|
39 |
|
40 public void setUp() throws Exception { |
|
41 wrapperMock = createMock(IIMakerWrapper.class); |
|
42 environment = new Environment(DRIVE); |
|
43 environment.setImakerWrapper(wrapperMock); |
|
44 } |
|
45 |
|
46 public void tearDown() throws Exception { |
|
47 wrapperMock = null; |
|
48 environment = null; |
|
49 } |
|
50 |
|
51 |
|
52 public void testCreate() throws Exception { |
|
53 assertNotNull(environment); |
|
54 assertEquals(DRIVE, environment.getDrive()); |
|
55 } |
|
56 |
|
57 public void testLoad() throws Exception { |
|
58 assertFalse(environment.isLoaded()); |
|
59 List<UIConfiguration> confs = new ArrayList<UIConfiguration>(); |
|
60 confs.add(new UIConfiguration(IQRFFactory.eINSTANCE.createConfiguration())); |
|
61 int numberOfconfs = confs.size(); |
|
62 expect(wrapperMock.getConfigurations(isA(IProgressMonitor.class))) |
|
63 .andReturn(confs); |
|
64 |
|
65 replay(wrapperMock); |
|
66 List<UIConfiguration> configurations = environment.load(); |
|
67 assertTrue(environment.isLoaded()); |
|
68 assertNotNull(configurations); |
|
69 assertTrue(configurations.size()>=numberOfconfs); |
|
70 assertTrue(environment.getConfigurations().size()>=numberOfconfs); |
|
71 assertSame(configurations, environment.getConfigurations()); |
|
72 verify(wrapperMock); |
|
73 } |
|
74 } |