imakerplugin/com.nokia.s60tools.imaker.tests/src/com/nokia/s60tools/imaker/internal/tests/IMakerWrapperTest.java
changeset 0 61163b28edca
child 2 a91cb670dd8e
equal deleted inserted replaced
-1:000000000000 0:61163b28edca
       
     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 
       
    18 package com.nokia.s60tools.imaker.internal.tests;
       
    19 
       
    20 
       
    21 import java.io.File;
       
    22 import java.io.FilenameFilter;
       
    23 import java.util.ArrayList;
       
    24 import java.util.List;
       
    25 
       
    26 import com.nokia.s60tools.imaker.IIMakerWrapper;
       
    27 import com.nokia.s60tools.imaker.UIConfiguration;
       
    28 import com.nokia.s60tools.imaker.internal.wrapper.IMakerWrapper;
       
    29 
       
    30 
       
    31 public class IMakerWrapperTest extends IMakerCoreTest {
       
    32 	
       
    33 	public void testImakerWrapperAgainsGivenStubs() throws Exception {
       
    34 		List<String> script = new ArrayList<String>();
       
    35 		File f = new File(iMakerStubPath);
       
    36 		String[] files = f.list(new FilenameFilter() {
       
    37 //			@Override
       
    38 			public boolean accept(File dir, String name) {
       
    39 				return name.startsWith("iMakerStub");
       
    40 			}
       
    41 		});
       
    42 		for (int i = 0; i < files.length; i++) {
       
    43 			script.add(PERL);
       
    44 			String stub = files[i];
       
    45 			String stubPath = iMakerStubPath + stub;
       
    46 			script.add(stubPath);
       
    47 			IIMakerWrapper wrapper = new IMakerWrapper(script);
       
    48 			String version = wrapper.getIMakerCoreVersion();
       
    49 			assertTrue("iMakerWrapper failed with stub " + stub, version!=null);
       
    50 			assertTrue("iMakerWrapper failed with stub " + stub, version.length()>1);
       
    51 			assertTrue("iMakerWrapper failed with stub " + stub, version.startsWith("iMaker"));
       
    52 
       
    53 			List<UIConfiguration> configs = wrapper.getConfigurations(null);
       
    54 			assertTrue("iMakerWrapper failed with stub " + stub, !configs.isEmpty());
       
    55 			UIConfiguration config = configs.get(0);
       
    56 			assertTrue("iMakerWrapper failed with stub " + stub, !config.getAllTargets().isEmpty());
       
    57 			assertTrue("iMakerWrapper failed with stub " + stub, !config.getVariables().isEmpty());
       
    58 
       
    59 			ArrayList<String> params = new ArrayList<String>();
       
    60 			params.add("test");
       
    61 			String command = wrapper.getBuildCommand(params);
       
    62 			assertNotNull("iMakerWrapper failed with stub " + stub, command);
       
    63 			params.clear();
       
    64 			params.add("-f");
       
    65 			params.add("mk");
       
    66 			params.add("flash");
       
    67 			boolean success = wrapper.buildImage(params, null);
       
    68 			assertTrue("iMakerWrapper failed with stub " + stub, success);
       
    69 			script.clear();
       
    70 		}
       
    71 	}
       
    72 }