/*
 * Copyright 2016 tascape.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.tascape.qa.android.demo.suite;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.tascape.qa.android.demo.driver.FDroid;
import com.tascape.qa.android.demo.test.FDroidSettingsTests;
import com.tascape.qa.android.demo.test.DeviceTests;
import com.tascape.qa.th.android.driver.UiAutomatorDevice;
import com.tascape.qa.th.android.suite.UiAutomatorTestSuite;
import com.tascape.qa.th.suite.AbstractSuite;

/**
 *
 * @author linsong wang
 */
public class SmokeSuite extends AbstractSuite implements UiAutomatorTestSuite {
    private static final Logger LOG = LoggerFactory.getLogger(SmokeSuite.class);

    private final FDroid droid = new FDroid();

    private UiAutomatorDevice device;

    @Override
    public void setUpTestClasses() {
        this.addTestClass(FDroidSettingsTests.class);
        this.addTestClass(DeviceTests.class);
    }

    @Override
    protected void setUpEnvironment() throws Exception {
        device = this.getAvailableDevice();
        droid.attachTo(device);
        device.takeDeviceScreenshot();

        this.putTestDirver(DeviceTests.MOBILE_DEVICE, device);

        this.putTestDirver(FDroidSettingsTests.MOBILE_DEVICE, device);
        this.putTestDirver(FDroidSettingsTests.MOBILE_APP, droid);
    }

    @Override
    protected void tearDownEnvironment() {
        if (device != null) {
            device.stop();
        }
    }

    @Override
    public String getProductUnderTest() {
        return droid.getName();
    }

    @Override
    public String getProjectName() {
        return "thx-android-demo";
    }

    @Override
    public int getNumberOfEnvs() {
        return SERIALS.size();
    }
}

@@ -847,24 +847,69 @@
 eviceTests;%0A
+import com.tascape.qa.th.android.driver.App;%0A
 import com.t
@@ -1061,16 +1061,61 @@
 ctSuite;
+%0Aimport org.apache.commons.lang3.StringUtils;
 %0A%0A/**%0A *
@@ -1661,24 +1661,230 @@
 leDevice();%0A
+        String apk = SYSCONFIG.getProperty(App.SYSPROP_APK_PATH);%0A        if (StringUtils.isNotEmpty(apk)) %7B%0A            device.uninstall(droid.getPackageName());%0A            device.install(apk);%0A        %7D%0A
         droi

update code to handle app installation