// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_INTELLIGENCE_ACTOR_TOOLS_TEST_ACTOR_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_INTELLIGENCE_ACTOR_TOOLS_TEST_ACTOR_APP_INTERFACE_H_

#import <Foundation/Foundation.h>

// Error domain for ActorAppInterface.
extern NSString* const kActorAppInterfaceErrorDomain;

// Error codes for ActorAppInterface.
typedef NS_ENUM(NSInteger, ActorAppInterfaceErrorCode) {
  ActorToolExecutionResultNoProfile = 1,
  ActorToolExecutionResultNoService = 2,
  ActorToolExecutionResultInvalidProto = 3,
  ActorToolExecutionResultNoActuationResults = 4,
  ActorToolExecutionResultNoWebState = 5,
  ActorToolExecutionResultNoMainFrame = 6,
};

// App interface to interact with the ActorService from integration tests.
@interface ActorAppInterface : NSObject

// Executes an Action defined by the serialized proto.
// The completion block is called when the action finishes or fails.
+ (void)executeActionWithProto:(NSData*)actionProto
                    completion:(void (^)(NSError* error))completion;

// Executes a list of Actions defined by the serialized Actions proto.
// The completion block is called when all actions finish or any action fails.
+ (void)executeActionsWithProto:(NSData*)actionsProto
                     completion:(void (^)(NSError* error))completion;

// Fetches the latest Annotated Page Content (APC) via the PageContextWrapper
// and returns the serialized optimization_guide::proto::PageContext.
+ (NSData*)fetchLatestAPC;

// Waits for page stability in the current main frame.
+ (void)waitForPageStabilityWithCompletion:(void (^)(NSError* error))completion;

// Sets the actuating state on the ActorTabHelper of the WebState at `index`.
+ (void)setActuating:(BOOL)actuating forWebStateAtIndex:(int)index;

// Simulates in-flight Autofill server predictions for the active `WebState`'s
// `AutofillManager` to hold `FormPredictionsTracker` in a waiting state.
+ (void)simulateInFlightAutofillPredictions;

// Resolves in-flight Autofill server predictions for the active `WebState`'s
// `AutofillManager` to unblock `FormPredictionsTracker`.
+ (void)resolveInFlightAutofillPredictions;

// Returns the current window ID.
+ (int32_t)currentWindowID;
@end

#endif  // IOS_CHROME_BROWSER_INTELLIGENCE_ACTOR_TOOLS_TEST_ACTOR_APP_INTERFACE_H_
