blob: 4213dabeb4124b7e4bff3f1d28070c8ff7727b7e [file] [log] [blame]
// 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 wallpaper
import (
"context"
"time"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/local/chrome/uiauto/faillog"
"chromiumos/tast/local/chrome/uiauto/nodewith"
"chromiumos/tast/local/chrome/uiauto/role"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: Change,
Desc: "Follows the user flow to change the wallpaper",
Contacts: []string{
"chromeos-sw-engprod@google.com",
},
Attr: []string{"group:mainline", "informational"},
SoftwareDeps: []string{"chrome"},
Fixture: "chromeLoggedIn",
})
}
func Change(ctx context.Context, s *testing.State) {
cr := s.FixtValue().(*chrome.Chrome)
tconn, err := cr.TestAPIConn(ctx)
if err != nil {
s.Fatal("Failed to create Test API connection: ", err)
}
defer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)
ui := uiauto.New(tconn)
setWallpaperMenu := nodewith.Name("Set wallpaper").Role(role.MenuItem)
if err := uiauto.Combine("change the wallpaper",
ui.RightClick(nodewith.ClassName("WallpaperView")),
// This button takes a bit before it is clickable.
// Keep clicking it until the click is received and the menu closes.
ui.WithInterval(500*time.Millisecond).LeftClickUntil(setWallpaperMenu, ui.Gone(setWallpaperMenu)),
ui.LeftClick(nodewith.Name("Solid colors").Role(role.StaticText)),
ui.LeftClick(nodewith.Name("Deep Purple").Role(role.ListItem)),
// Ensure that "Deep Purple" text is displayed.
// The UI displays the name of the currently set wallpaper.
ui.WaitUntilExists(nodewith.Name("Deep Purple").Role(role.StaticText)),
)(ctx); err != nil {
s.Fatal("Failed to change the wallpaper: ", err)
}
}