blob: 036fbfe47ee4ceb390b6ae9b6c879763d7394b2e [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 filemanager
import (
func init() {
Func: DrivefsGoogleDoc,
Desc: "Verify that a google doc created via Drive API syncs to DriveFS",
Contacts: []string{
SoftwareDeps: []string{
Attr: []string{
Timeout: 5 * time.Minute,
Pre: pre.DriveFsStarted,
VarDeps: []string{
func DrivefsGoogleDoc(ctx context.Context, s *testing.State) {
APIClient := s.PreValue().(drivefs.PreData).APIClient
tconn := s.PreValue().(drivefs.PreData).TestAPIConn
// Current refresh period is 2 minutes, leaving buffer for UI propagation.
// TODO(crbug/1112246): Reduce refresh period once push notifications fixed.
const filesAppUITimeout = 3 * time.Minute
testDocFileName := fmt.Sprintf("doc-drivefs-%d-%d", time.Now().UnixNano(), rand.Intn(10000))
// Create a blank Google doc in the root GDrive directory.
file, err := APIClient.CreateBlankGoogleDoc(ctx, testDocFileName, []string{"root"})
if err != nil {
s.Fatal("Could not create blank google doc: ", err)
defer APIClient.RemoveFileByID(ctx, file.Id)
defer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)
// Launch Files App and check that Drive is accessible.
filesApp, err := filesapp.Launch(ctx, tconn)
if err != nil {
s.Fatal("Could not launch the Files App: ", err)
defer filesApp.Release(ctx)
// Navigate to Google Drive via the Files App ui.
if err := filesApp.OpenDrive(ctx); err != nil {
s.Fatal("Could not open Google Drive folder: ", err)
// Check for the test file created earlier.
testFileNameWithExt := fmt.Sprintf("%s.gdoc", testDocFileName)
if err := filesApp.WaitForFile(ctx, testFileNameWithExt, filesAppUITimeout); err != nil {
s.Fatalf("Could not find the test file %q in Drive: %v", testFileNameWithExt, err)