/
optin.go
78 lines (68 loc) · 1.96 KB
/
optin.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
// 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 arc
import (
"context"
"time"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/arc/optin"
"chromiumos/tast/local/chrome"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: Optin,
LacrosStatus: testing.LacrosVariantUnneeded,
Desc: "A functional test that verifies OptIn flow",
Contacts: []string{
"arc-core@google.com",
"mhasank@chromium.org",
"khmel@chromium.org", // author.
},
Attr: []string{"group:mainline", "group:arc-functional"},
VarDeps: []string{"ui.gaiaPoolDefault"},
SoftwareDeps: []string{
"chrome",
"chrome_internal",
"play_store",
},
Params: []testing.Param{{
ExtraSoftwareDeps: []string{"android_p"},
}, {
Name: "vm",
ExtraSoftwareDeps: []string{"android_vm"},
}},
Timeout: 6 * time.Minute,
})
}
// Optin tests optin flow.
func Optin(ctx context.Context, s *testing.State) {
const (
// If a single variant is flaky, please promote this to test params and increase the
// attempts only for that specific variant instead of updating the constant for all.
// See crrev.com/c/2979454 for an example.
maxAttempts = 1
)
gaiaLogin := chrome.GAIALoginPool(s.RequiredVar("ui.gaiaPoolDefault"))
cr, err := setupChrome(ctx, gaiaLogin)
if err != nil {
s.Fatal("Failed to start Chrome: ", err)
}
defer cr.Close(ctx)
s.Log("Performing optin")
if err := optin.PerformWithRetry(ctx, cr, maxAttempts); err != nil {
s.Fatal("Failed to optin: ", err)
}
}
// setupChrome starts chrome with pooled GAIA account and ARC enabled.
func setupChrome(ctx context.Context, gaiaLogin chrome.Option) (*chrome.Chrome, error) {
cr, err := chrome.New(ctx,
gaiaLogin,
chrome.ARCSupported(),
chrome.ExtraArgs(arc.DisableSyncFlags()...))
if err != nil {
return nil, err
}
return cr, nil
}