Class: Fastlane::Actions::AnnaiCloseEmulatorsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb

Overview


AnnaiCloseEmulatorsAction


Class Method Summary collapse

Class Method Details

.available_optionsObject


Define Parameters




144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 144

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :platform,
                                 description: "The platform (:ios or :android)",
                                 is_string: false,
                                 verify_block: proc do |value|
                                    UI.user_error!("Platform must be :ios or :android") unless [:ios, :android].include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :test_spec_file,
                                 description: "Path to the annai test spec configuration file (relative to flutter root). Defaults to standard discovery",
                                 optional: true,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :emulator,
                                 description: "The specific emulator/device name (as defined in the test spec) to close. If nil, all defined emulators for the platform will be closed.",
                                 optional: true,
                                 type: String,
                                 default_value: nil)
  ].compact
end

.descriptionObject



164
165
166
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 164

def self.description
  "Closes the specified emulators or all emulators defined in the Annai test spec file."
end

.example_codeObject



172
173
174
175
176
177
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 172

def self.example_code
  'annai_close_emulators(
    platform: :android,
    emulator: "Pixel_5_API_30"
  )'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 168

def self.is_supported?(platform)
  [:ios, :android].include?(platform)
end

.run(params) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 107

def self.run(params)
  platform = params[:platform]
  UI.header("Starting Annai Close Emulators for #{platform}")

  # 1. Determine the necessary paths and managers
  root_folder = FastlaneFlutterFlavor::ProjectUtil.find_flutter_root

  # Resolve the test spec file path
  test_spec_file_input = params[:test_spec_file]
  resolved_test_spec_path = FastlaneFlutterFlavor::ProjectUtil.find_annai_test_spec_path(test_spec_file_input)

  # Status Manager is required by IntegrationTest's constructor
  status_manager = FastlaneFlutterFlavor::StatusManager.new(lane: self)

  # 2. Instantiate IntegrationTest helper
  integration_test = FastlaneFlutterFlavor::IntegrationTest.new(
    lane: self,
    isAndroid: platform == :android,
    isIos: platform == :ios,
    test_spec_file: resolved_test_spec_path,
    statusManager: status_manager,
    root_folder: root_folder
  )

  # 3. Call the closeEmulators method
  integration_test.closeEmulators(
    options: {
      emulator: params[:emulator]
    }
  )

  UI.success("✅ Emulator(s) shut down successfully for #{platform}.")
end