blob: bff7508407d7582f2336512ec282c827f62aed70 [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 camera
import (
"context"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/local/camera/cca"
"chromiumos/tast/local/camera/testutil"
"chromiumos/tast/local/chrome"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: CCAUIRefresh,
Desc: "Test for checking Chrome Camera App still works after refreshing",
Contacts: []string{"wtlee@chromium.org", "chromeos-camera-eng@google.com"},
Attr: []string{"group:mainline", "informational", "group:camera-libcamera"},
SoftwareDeps: []string{"camera_app", "chrome", caps.BuiltinOrVividCamera},
Data: []string{"cca_ui.js"},
Pre: chrome.LoggedIn(),
})
}
func CCAUIRefresh(ctx context.Context, s *testing.State) {
cr := s.PreValue().(*chrome.Chrome)
tb, err := testutil.NewTestBridge(ctx, cr, testutil.UseRealCamera)
if err != nil {
s.Fatal("Failed to construct test bridge: ", err)
}
defer tb.TearDown(ctx)
if err := cca.ClearSavedDirs(ctx, cr); err != nil {
s.Fatal("Failed to clear saved directory: ", err)
}
app, err := cca.New(ctx, cr, []string{s.DataPath("cca_ui.js")}, s.OutDir(), tb)
if err != nil {
s.Fatal("Failed to open CCA: ", err)
}
defer func(ctx context.Context) {
if err := app.Close(ctx); err != nil {
s.Error("Failed to close app: ", err)
}
}(ctx)
s.Log("Refreshing CCA")
if err := app.Refresh(ctx, tb); err != nil {
s.Fatal("Failed to complete refresh: ", err)
}
if err := app.WaitForVideoActive(ctx); err != nil {
s.Fatal("Preview is not shown after refreshing: ", err)
}
}