/
standardized_mouse_right_click.go
85 lines (71 loc) · 3.3 KB
/
standardized_mouse_right_click.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2021 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 arc
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/arc/standardizedtestutil"
"chromiumos/tast/local/input"
"chromiumos/tast/testing"
"chromiumos/tast/testing/hwdep"
)
func init() {
testing.AddTest(&testing.Test{
Func: StandardizedMouseRightClick,
LacrosStatus: testing.LacrosVariantUnneeded,
Desc: "Functional test that installs an app and tests standard mouse right click functionality. Tests are only performed in clamshell mode as tablets don't allow mice",
Contacts: []string{"davidwelling@google.com", "cros-appcompat-test-team@google.com"},
Attr: []string{"group:mainline", "informational"},
SoftwareDeps: []string{"chrome", "no_chrome_dcheck"},
Timeout: 10 * time.Minute,
Fixture: "arcBooted",
Params: []testing.Param{{
Val: standardizedtestutil.GetClamshellTest(runStandardizedMouseRightClickTest),
ExtraSoftwareDeps: []string{"android_p"},
ExtraHardwareDeps: hwdep.D(standardizedtestutil.ClamshellHardwareDep),
}, {
Name: "vm",
Val: standardizedtestutil.GetClamshellTest(runStandardizedMouseRightClickTest),
ExtraSoftwareDeps: []string{"android_vm"},
ExtraHardwareDeps: hwdep.D(standardizedtestutil.ClamshellHardwareDep),
}},
})
}
func StandardizedMouseRightClick(ctx context.Context, s *testing.State) {
const (
apkName = "ArcStandardizedInputTest.apk"
appName = "org.chromium.arc.testapp.arcstandardizedinputtest"
activityName = ".PointerRightClickTestActivity"
)
t := s.Param().(standardizedtestutil.Test)
standardizedtestutil.RunTest(ctx, s, apkName, appName, activityName, t)
}
func runStandardizedMouseRightClickTest(ctx context.Context, testParameters standardizedtestutil.TestFuncParams) error {
btnRightClickID := testParameters.AppPkgName + ":id/btnRightClick"
btnRightClickSelector := testParameters.Device.Object(ui.ID(btnRightClickID))
// Setup the mouse.
mouse, err := input.Mouse(ctx)
if err != nil {
return errors.Wrap(err, "unable to setup the mouse")
}
defer mouse.Close()
if err := btnRightClickSelector.WaitForExists(ctx, standardizedtestutil.ShortUITimeout); err != nil {
return errors.Wrap(err, "unable to find the button to click")
}
if err := testParameters.Device.Object(ui.Text("POINTER RIGHT CLICK (1)")).WaitUntilGone(ctx, standardizedtestutil.ShortUITimeout); err != nil {
return errors.Wrap(err, "the success label should not yet exist")
}
if err := standardizedtestutil.MouseClickObject(ctx, testParameters, btnRightClickSelector, mouse, standardizedtestutil.RightPointerButton); err != nil {
return errors.Wrap(err, "unable to click the button")
}
if err := testParameters.Device.Object(ui.Text("POINTER RIGHT CLICK (1)")).WaitForExists(ctx, standardizedtestutil.ShortUITimeout); err != nil {
return errors.Wrap(err, "the success label should exist")
}
if err := testParameters.Device.Object(ui.Text("POINTER RIGHT CLICK (2)")).WaitUntilGone(ctx, standardizedtestutil.ShortUITimeout); err != nil {
return errors.Wrap(err, "a single mouse click triggered two click events")
}
return nil
}