blob: 5a25dd40021b19ed419e6c1ca5581ae2291b546a [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 typec
import (
func init() {
Register: func(srv *grpc.Server, s *testing.ServiceState) {
typec.RegisterServiceServer(srv, &Service{s: s})
// Service implements tast.cros.typec.Service.
type Service struct {
s *testing.ServiceState
cr *chrome.Chrome
// NewChromeLoginWithPeripheralDataAccess logs in to Chrome as a fake user, but before that, enables the DevicePciPeripheralDataAccess setting.
func (c *Service) NewChromeLoginWithPeripheralDataAccess(ctx context.Context, req *typec.KeyPath) (*empty.Empty, error) {
// Get to the Chrome login screen.
cr, err := chrome.New(ctx,
if err != nil {
return nil, errors.Wrap(err, "failed to start Chrome at login screen")
// Enable the setting.
if err := typecutils.EnablePeripheralDataAccess(ctx, req.Path); err != nil {
return nil, errors.Wrap(err, "failed to enable peripheral data access setting")
if err := cr.ContinueLogin(ctx); err != nil {
return nil, errors.Wrap(err, "failed to login")
} = cr
return &empty.Empty{}, nil