blob: da249e279bb59ce1536fa1f73a124840d80045ed [file] [log] [blame]
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package arcappcompat will have tast tests for android apps on Chromebooks.
package arcappcompat
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/bundles/cros/arcappcompat/pre"
"chromiumos/tast/local/bundles/cros/arcappcompat/testutil"
"chromiumos/tast/local/chrome"
"chromiumos/tast/testing"
"chromiumos/tast/testing/hwdep"
)
// clamshellLaunchForCrossDJ launches CrossDJ in clamshell mode.
var clamshellLaunchForCrossDJ = []testutil.TestCase{
{Name: "Launch app in Clamshell", Fn: launchAppForCrossDJ},
}
// touchviewLaunchForCrossDJ launches CrossDJ in tablet mode.
var touchviewLaunchForCrossDJ = []testutil.TestCase{
{Name: "Launch app in Touchview", Fn: launchAppForCrossDJ},
}
func init() {
testing.AddTest(&testing.Test{
Func: CrossDJ,
LacrosStatus: testing.LacrosVariantUnneeded,
Desc: "Functional test for CrossDJ that installs the app also verifies it is logged in and that the main page is open, checks CrossDJ correctly changes the window state in both clamshell and touchview mode",
Contacts: []string{"cros-appcompat-test-team@google.com"},
Attr: []string{"group:appcompat"},
SoftwareDeps: []string{"chrome"},
HardwareDeps: hwdep.D(hwdep.SkipOnModel("elm")),
Params: []testing.Param{{
Name: "clamshell_mode",
Val: testutil.TestParams{
LaunchTests: clamshellLaunchForCrossDJ,
CommonTests: testutil.ClamshellCommonTests,
},
ExtraSoftwareDeps: []string{"android_p"},
// TODO(b/189704585): Remove hwdep.SkipOnModel once the solution is found.
// Skip on tablet only models.
ExtraHardwareDeps: hwdep.D(hwdep.SkipOnModel(testutil.TabletOnlyModels...)),
Pre: pre.AppCompatBootedForCrossDJ,
}, {
Name: "tablet_mode",
Val: testutil.TestParams{
LaunchTests: touchviewLaunchForCrossDJ,
CommonTests: testutil.TouchviewCommonTests,
},
ExtraSoftwareDeps: []string{"android_p"},
// TODO(b/189704585): Remove hwdep.SkipOnModel once the solution is found.
// Skip on clamshell only models.
ExtraHardwareDeps: hwdep.D(hwdep.TouchScreen(), hwdep.SkipOnModel(testutil.ClamshellOnlyModels...)),
Pre: pre.AppCompatBootedInTabletModeForCrossDJ,
}, {
Name: "vm_clamshell_mode",
Val: testutil.TestParams{
LaunchTests: clamshellLaunchForCrossDJ,
CommonTests: testutil.ClamshellCommonTests,
},
ExtraSoftwareDeps: []string{"android_vm"},
// TODO(b/189704585): Remove hwdep.SkipOnModel once the solution is found.
// Skip on tablet only models.
ExtraHardwareDeps: hwdep.D(hwdep.SkipOnModel(testutil.TabletOnlyModels...)),
Pre: pre.AppCompatBootedForCrossDJ,
}, {
Name: "vm_tablet_mode",
Val: testutil.TestParams{
LaunchTests: touchviewLaunchForCrossDJ,
CommonTests: testutil.TouchviewCommonTests,
},
ExtraSoftwareDeps: []string{"android_vm"},
// TODO(b/189704585): Remove hwdep.SkipOnModel once the solution is found.
// Skip on clamshell only models.
ExtraHardwareDeps: hwdep.D(hwdep.TouchScreen(), hwdep.SkipOnModel(testutil.ClamshellOnlyModels...)),
Pre: pre.AppCompatBootedInTabletModeForCrossDJ,
}},
Timeout: 10 * time.Minute,
VarDeps: []string{"arcappcompat.CrossDJ.username", "arcappcompat.CrossDJ.password"},
})
}
// CrossDJ test uses library for opting into the playstore and installing app.
// Checks CrossDJ correctly changes the window states in both clamshell and touchview mode.
func CrossDJ(ctx context.Context, s *testing.State) {
const (
appPkgName = "com.mixvibes.crossdjapp"
appActivity = "com.mixvibes.crossdj.CrossDJActivity"
)
testSet := s.Param().(testutil.TestParams)
testutil.RunTestCases(ctx, s, appPkgName, appActivity, testSet)
}
// launchAppForCrossDJ verifies app is logged in and
// verify app reached main activity page of the app.
func launchAppForCrossDJ(ctx context.Context, s *testing.State, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, appPkgName, appActivity string) {
testutil.HandleDialogBoxes(ctx, s, d, appPkgName)
// Check for launch verifier.
launchVerifier := d.Object(ui.PackageName(appPkgName))
if err := launchVerifier.WaitForExists(ctx, testutil.LongUITimeout); err != nil {
testutil.DetectAndHandleCloseCrashOrAppNotResponding(ctx, s, d)
s.Fatal("launchVerifier doesn't exists: ", err)
}
}