Add a couple more tests for package platform migration

Change-Id: I26073544349cd0646ac277656d44be5c80242c39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337262
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/platform_use_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/platform_use_case_test.dart
index a8da252..75f86c7 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/platform_use_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/platform_use_case_test.dart
@@ -15,6 +15,61 @@
 
 @reflectiveTest
 class PlatformUseCaseTest extends DataDrivenFixProcessorTest {
+  @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/54103')
+  Future<void> test_package_os_detect_platform_deprecated() async {
+    newFile('$workspaceRootPath/p/lib/os.dart', '''
+  @deprecated
+  bool get isAndroid => true;
+''');
+    newFile('$workspaceRootPath/p2/lib/host.dart', '''
+ class HostPlatform {
+  static HostPlatform get current => HostPlatform();
+  bool get isAndroid => true;
+}
+''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'p', rootPath: '$workspaceRootPath/p')
+        ..add(name: 'p2', rootPath: '$workspaceRootPath/p2'),
+    );
+
+    addPackageDataFile('''
+version: 1
+transforms:
+  - title: 'Replace package os_detect by package platform HostPlatform'
+    date: 2023-11-09
+    element:
+      uris: [  'package:p/os.dart' ]
+      function: 'isAndroid'
+    changes:
+    - kind: 'replacedBy'
+      replaceTarget: true
+      newElement:
+        uris: [  'package:p2/host.dart' ]
+        getter: current.isAndroid
+        inClass: HostPlatform
+        static: true
+''');
+
+    await resolveTestCode('''
+import 'package:p/os.dart' as Platform;
+main() {
+  bool onAndroid = Platform.isAndroid;
+  print(onAndroid);
+}
+''');
+    await assertHasFix('''
+import 'package:p/os.dart' as Platform;
+import 'package:p2/host.dart';
+
+main() {
+  bool onAndroid = HostPlatform.current.isAndroid;
+  print(hostname);
+}
+''');
+  }
+
   Future<void> test_platform_LocalPlatform_isAndroid_deprecated() async {
     newFile('$workspaceRootPath/p/lib/lib.dart', '''
 class LocalPlatform {
@@ -71,4 +126,61 @@
 }
 ''');
   }
+
+  Future<void> test_platform_LocalPlatform_localHostname_deprecated() async {
+    newFile('$workspaceRootPath/p/lib/lib.dart', '''
+class LocalPlatform {
+  @deprecated
+  String get localHostname => 'hostname';
+}
+''');
+    newFile('$workspaceRootPath/p/lib/native.dart', '''
+class NativePlatform {
+  static NativePlatform get current => NativePlatform();
+  String get localHostname => 'hostname';
+}
+''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'p', rootPath: '$workspaceRootPath/p'),
+    );
+
+    addPackageDataFile('''
+version: 1
+transforms:
+  - title: 'Replace by NativePlatform'
+    date: 2023-11-09
+    element:
+      uris: [  '$importUri' ]
+      getter: 'localHostname'
+      inClass: LocalPlatform
+    changes:
+    - kind: 'replacedBy'
+      replaceTarget: true
+      newElement:
+        uris: [  'package:p/native.dart' ]
+        getter: current.localHostname
+        inClass: NativePlatform
+        static: true
+''');
+
+    await resolveTestCode('''
+import '$importUri';
+
+main() {
+  var hostname =  LocalPlatform().localHostname;
+  print(hostname);
+}
+''');
+    await assertHasFix('''
+import '$importUri';
+import 'package:p/native.dart';
+
+main() {
+  var hostname =  NativePlatform.current.localHostname;
+  print(hostname);
+}
+''');
+  }
 }