imakerplugin/com.nokia.s60tools.imaker.tests/src/com/nokia/s60tools/imaker/internal/tests/IMakerWrapperTest.java
author haismail <hussein.ismail@nokia.com>
Tue, 09 Feb 2010 17:10:58 +0200
changeset 2 a91cb670dd8e
parent 0 61163b28edca
permissions -rw-r--r--
iMaker plugin updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description: 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
package com.nokia.s60tools.imaker.internal.tests;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import java.io.File;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import java.io.FilenameFilter;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import java.util.ArrayList;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import java.util.List;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
import com.nokia.s60tools.imaker.IIMakerWrapper;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
import com.nokia.s60tools.imaker.UIConfiguration;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
import com.nokia.s60tools.imaker.internal.wrapper.IMakerWrapper;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
public class IMakerWrapperTest extends IMakerCoreTest {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
	public void testImakerWrapperAgainsGivenStubs() throws Exception {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
		List<String> script = new ArrayList<String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
		File f = new File(iMakerStubPath);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
		String[] files = f.list(new FilenameFilter() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
			public boolean accept(File dir, String name) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
				return name.startsWith("iMakerStub");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
		for (int i = 0; i < files.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
			script.add(PERL);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
			String stub = files[i];
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
			String stubPath = iMakerStubPath + stub;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
			script.add(stubPath);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
			IIMakerWrapper wrapper = new IMakerWrapper(script);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
			String version = wrapper.getIMakerCoreVersion();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
			assertTrue("iMakerWrapper failed with stub " + stub, version!=null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
			assertTrue("iMakerWrapper failed with stub " + stub, version.length()>1);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
			assertTrue("iMakerWrapper failed with stub " + stub, version.startsWith("iMaker"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
2
a91cb670dd8e iMaker plugin updated
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
    53
			List<UIConfiguration> configs = wrapper.getConfigurations(null,null);
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
			assertTrue("iMakerWrapper failed with stub " + stub, !configs.isEmpty());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
			ArrayList<String> params = new ArrayList<String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
			params.add("test");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
			String command = wrapper.getBuildCommand(params);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
			assertNotNull("iMakerWrapper failed with stub " + stub, command);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
			params.clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
			params.add("-f");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
			params.add("mk");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
			params.add("flash");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
			boolean success = wrapper.buildImage(params, null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
			assertTrue("iMakerWrapper failed with stub " + stub, success);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
			script.clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
}