blob: 373d24858e6c7b49b6333656269db46eb571d4c0 [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 crostini
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/local/crostini"
"chromiumos/tast/local/crostini/ui/settings"
"chromiumos/tast/local/vm"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: ResizeCancel,
Desc: "Test cancelling resizing of Crostini from the Settings app",
Contacts: []string{"jinrongwu@google.com", "cros-containers-dev@google.com"},
Attr: []string{"group:mainline", "informational"},
SoftwareDeps: []string{"chrome", "vm_host"},
Vars: []string{"keepState"},
VarDeps: []string{"ui.gaiaPoolDefault"},
Params: []testing.Param{
// Parameters generated by params_test.go. DO NOT EDIT.
{
Name: "stretch_stable",
ExtraData: []string{crostini.GetContainerMetadataArtifact("stretch", false), crostini.GetContainerRootfsArtifact("stretch", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniStable,
Pre: crostini.StartedByDlcStretch(),
Timeout: 7 * time.Minute,
}, {
Name: "stretch_unstable",
ExtraAttr: []string{"informational"},
ExtraData: []string{crostini.GetContainerMetadataArtifact("stretch", false), crostini.GetContainerRootfsArtifact("stretch", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniUnstable,
Pre: crostini.StartedByDlcStretch(),
Timeout: 7 * time.Minute,
}, {
Name: "buster_stable",
ExtraData: []string{crostini.GetContainerMetadataArtifact("buster", false), crostini.GetContainerRootfsArtifact("buster", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniStable,
Pre: crostini.StartedByDlcBuster(),
Timeout: 7 * time.Minute,
}, {
Name: "buster_unstable",
ExtraAttr: []string{"informational"},
ExtraData: []string{crostini.GetContainerMetadataArtifact("buster", false), crostini.GetContainerRootfsArtifact("buster", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniUnstable,
Pre: crostini.StartedByDlcBuster(),
Timeout: 7 * time.Minute,
}, {
Name: "bullseye_stable",
ExtraAttr: []string{"informational"},
ExtraData: []string{crostini.GetContainerMetadataArtifact("bullseye", false), crostini.GetContainerRootfsArtifact("bullseye", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniStable,
Pre: crostini.StartedByDlcBullseye(),
Timeout: 7 * time.Minute,
}, {
Name: "bullseye_unstable",
ExtraAttr: []string{"informational"},
ExtraData: []string{crostini.GetContainerMetadataArtifact("bullseye", false), crostini.GetContainerRootfsArtifact("bullseye", false)},
ExtraSoftwareDeps: []string{"dlc"},
ExtraHardwareDeps: crostini.CrostiniUnstable,
Pre: crostini.StartedByDlcBullseye(),
Timeout: 7 * time.Minute,
},
},
})
}
func ResizeCancel(ctx context.Context, s *testing.State) {
pre := s.PreValue().(crostini.PreData)
tconn := pre.TestAPIConn
cr := s.PreValue().(crostini.PreData).Chrome
// Use a shortened context for test operations to reserve time for cleanup.
cleanupCtx := ctx
ctx, cancel := ctxutil.Shorten(ctx, 30*time.Second)
defer cancel()
defer crostini.RunCrostiniPostTest(cleanupCtx, pre)
// Open the Linux settings.
st, err := settings.OpenLinuxSettings(ctx, tconn, cr)
if err != nil {
s.Fatal("Failed to open Linux Settings: ", err)
}
defer st.Close(cleanupCtx)
disk, err := pre.Container.VM.Concierge.GetVMDiskInfo(ctx, vm.DefaultVMName)
if err != nil {
s.Fatal("Failed to get VM disk info: ", err)
}
originalContDS := disk.GetSize()
originalDSOnSettings, err := st.GetDiskSize(ctx)
if err != nil {
s.Fatal("Failed to get the disk size from the Settings app: ", err)
}
// Click Resize on Linux settings page.
ui := uiauto.New(tconn)
if err := uiauto.Combine("open Resize dialog and click button Cancel",
st.ClickChange(),
ui.LeftClick(settings.ResizeDiskDialog.Cancel),
ui.WaitUntilGone(settings.ResizeDiskDialog.Self))(ctx); err != nil {
s.Fatal("Failed to cancel resize: ", err)
}
newDSOnSettings, err := st.GetDiskSize(ctx)
if err != nil {
s.Fatal("Failed to get the disk size from the Settings app after cancelling resizing: ", err)
}
disk, err = pre.Container.VM.Concierge.GetVMDiskInfo(ctx, vm.DefaultVMName)
if err != nil {
s.Fatal("Failed to get VM disk info after cancelling resizing: ", err)
}
newContDS := disk.GetSize()
if originalContDS != newContDS {
s.Fatalf("Failed to verify disk size of Crostini after cancelling resizing, got %d, want %d", newContDS, originalContDS)
}
if originalDSOnSettings != newDSOnSettings {
s.Fatalf("Failed to verify disk size on the Settings app after cancelling resizing, got %s, want %s", newDSOnSettings, originalDSOnSettings)
}
}