-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 69cf1df into dev
- Loading branch information
Showing
8 changed files
with
1,236 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
pkg/analysis_server/test/src/services/correction/fix/data_driven/platform_use_case_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../fix_processor.dart'; | ||
import 'data_driven_test_support.dart'; | ||
|
||
void main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(PlatformUseCaseTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class PlatformUseCaseTest extends DataDrivenFixProcessorTest { | ||
Future<void> test_platform_LocalPlatform_isAndroid_deprecated() async { | ||
newFile('$workspaceRootPath/p/lib/lib.dart', ''' | ||
class LocalPlatform { | ||
@deprecated | ||
bool get isAndroid => true; | ||
} | ||
'''); | ||
newFile('$workspaceRootPath/p/lib/host.dart', ''' | ||
class HostPlatform { | ||
static HostPlatform get current => HostPlatform(); | ||
bool get isAndroid => true; | ||
} | ||
'''); | ||
|
||
writeTestPackageConfig( | ||
config: PackageConfigFileBuilder() | ||
..add(name: 'p', rootPath: '$workspaceRootPath/p'), | ||
); | ||
|
||
addPackageDataFile(''' | ||
version: 1 | ||
transforms: | ||
- title: 'Replace by HostPlatform' | ||
date: 2023-11-09 | ||
element: | ||
uris: [ '$importUri' ] | ||
getter: 'isAndroid' | ||
inClass: LocalPlatform | ||
changes: | ||
- kind: 'replacedBy' | ||
replaceTarget: true | ||
newElement: | ||
uris: [ 'package:p/host.dart' ] | ||
getter: current.isAndroid | ||
inClass: HostPlatform | ||
static: true | ||
'''); | ||
|
||
await resolveTestCode(''' | ||
import '$importUri'; | ||
main() { | ||
var isAndroid = LocalPlatform().isAndroid; | ||
print(isAndroid); | ||
} | ||
'''); | ||
await assertHasFix(''' | ||
import 'package:p/host.dart'; | ||
import '$importUri'; | ||
main() { | ||
var isAndroid = HostPlatform.current.isAndroid; | ||
print(isAndroid); | ||
} | ||
'''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.