Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fb1a165 authored by Evan Laird's avatar Evan Laird Committed by Matt Pietal
Browse files

Remove whitespace from all test functions.

This was generated by running this exact query (who knows what tools
that line will break):

rg "fun \`" -l | xargs -I {} gsed -i -e '/fun `/s/\(\s*\)fun /\1DONOTSUBMIT/' -e '/DONOTSUBMIT/s/ - /_/g' -e '/DONOTSUBMIT/s/--/_/g' -e '/DONOTSUBMIT/s/\([a-z]\) \([a-z]\)/\1 \U\2/g' -e '/DONOTSUBMIT/s/\s//g' -e '/DONOTSUBMIT/s/`//g' -e '/DONOTSUBMIT/s/DONOTSUBMIT/DONOTSUBMIT /g' -e '/DONOTSUBMIT/s/ \([A-Z]\)\([a-z]\)/ \L\1\2/' -e '/DONOTSUBMIT/s/-\(\S\)/\U\1/g' -e '/DONOTSUBMIT/s/=/ = /' -e '/DONOTSUBMIT/s/{/ { /' -e '/DONOTSUBMIT/s/\s*$//' -e '/DONOTSUBMIT/s/DONOTSUBMIT/    fun/g' {}

The breakdown is as follows:

- rg queries for any file that contains a function which begins with
  "fun `"
- xargs to execute `gsed` on every file

Now for the transformation. Loosely what we do is:

- Replace "fun `" with an easily spottable tag
- Every command henceforth is filtered to lines starting with our tag
- Make the following transforms:
  1. replace " - " with a regular underscore
  2. replace the few "--" also with an underscore
  3. Any word following a space is uppercased
  4. Strip all whitespce from the whole line
  5. Remove the backtick
  6a. Add a space after our tag (important for the next step)
  6b. Any function starting with UpperCamelCase is now lowerCamelCase
  7. replace any <letter>-<letter> occurences with
     <letter><UPPERLETTER>. Because I figure "word-pair" is probably
     better represented as "wordPair" rather than "word_pair"
  8. re-add whitespace around the equals sign (if any)
  9. re-add whitespace around the opening bracket (if any)
  10. trim tailing whitespace
  11. replace our token with the corect "    fun" line starter

-e '/fun `/s/\(\s*\)fun /\1DONOTSUBMIT/'          #step 0
-e '/DONOTSUBMIT/s/ - /_/g'                       #step 1
-e '/DONOTSUBMIT/s/--/_/g'                        #step 2
-e '/DONOTSUBMIT/s/\([a-z]\) \([a-z]\)/\1 \U\2/g' #step 3
-e '/DONOTSUBMIT/s/\s//g'                         #step 4
-e '/DONOTSUBMIT/s/`//g'                          #step 5
-e '/DONOTSUBMIT/s/DONOTSUBMIT/DONOTSUBMIT /g'    #step 6a
-e '/DONOTSUBMIT/s/ \([A-Z]\)\([a-z]\)/ \L\1\2/'  #step 6b
-e '/DONOTSUBMIT/s/-\(\S\)/\U\1/g'                #step 7
-e '/DONOTSUBMIT/s/=/ = /'                        #step 8
-e '/DONOTSUBMIT/s/{/ { /'                        #step 9
-e '/DONOTSUBMIT/s/\s*$//'                        #step 10
-e '/DONOTSUBMIT/s/DONOTSUBMIT/    fun/g' {}      #step 11

NOTE: This CL skipped ktfmt since that only modified lines unrelated to
the change

Test: run all of the tests
Bug: 277739595
Change-Id: I673ebf8992f56f0220652e15534acdb91e60a9dc
parent 3273d2f9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class CleanArchitectureDependencyViolationDetectorTest : SystemUILintDetectorTes
    }

    @Test
    fun `No violations`() {
    fun noViolations() {
        lint()
            .files(
                *LEGITIMATE_FILES,
@@ -51,7 +51,7 @@ class CleanArchitectureDependencyViolationDetectorTest : SystemUILintDetectorTes
    }

    @Test
    fun `Violation - domain depends on ui`() {
    fun violation_domainDependsOnUi() {
        lint()
            .files(
                *LEGITIMATE_FILES,
@@ -86,7 +86,7 @@ class CleanArchitectureDependencyViolationDetectorTest : SystemUILintDetectorTes
    }

    @Test
    fun `Violation - ui depends on data`() {
    fun violation_uiDependsOnData() {
        lint()
            .files(
                *LEGITIMATE_FILES,
@@ -121,7 +121,7 @@ class CleanArchitectureDependencyViolationDetectorTest : SystemUILintDetectorTes
    }

    @Test
    fun `Violation - shared depends on all other layers`() {
    fun violation_sharedDependsOnAllOtherLayers() {
        lint()
            .files(
                *LEGITIMATE_FILES,
@@ -166,7 +166,7 @@ class CleanArchitectureDependencyViolationDetectorTest : SystemUILintDetectorTes
    }

    @Test
    fun `Violation - data depends on domain`() {
    fun violation_dataDependsOnDomain() {
        lint()
            .files(
                *LEGITIMATE_FILES,
+13 −13
Original line number Diff line number Diff line
@@ -172,64 +172,64 @@ class CameraGestureHelperTest : SysuiTestCase() {
    }

    @Test
    fun `canCameraGestureBeLaunched - status bar state is keyguard - returns true`() {
    fun canCameraGestureBeLaunched_statusBarStateIsKeyguard_returnsTrue() {
        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.KEYGUARD)).isTrue()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is shade-locked - returns true`() {
    fun canCameraGestureBeLaunched_stateIsShadeLocked_returnsTrue() {
        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.SHADE_LOCKED)).isTrue()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is keyguard - camera activity on top - returns true`() {
    fun canCameraGestureBeLaunched_stateIsKeyguard_cameraActivityOnTop_returnsTrue() {
        prepare(isCameraActivityRunningOnTop = true)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.KEYGUARD)).isTrue()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is shade-locked - camera activity on top - true`() {
    fun canCameraGestureBeLaunched_stateIsShadeLocked_cameraActivityOnTop_true() {
        prepare(isCameraActivityRunningOnTop = true)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.SHADE_LOCKED)).isTrue()
    }

    @Test
    fun `canCameraGestureBeLaunched - not allowed by admin - returns false`() {
    fun canCameraGestureBeLaunched_notAllowedByAdmin_returnsFalse() {
        prepare(isCameraAllowedByAdmin = false)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.KEYGUARD)).isFalse()
    }

    @Test
    fun `canCameraGestureBeLaunched - intent does not resolve to any app - returns false`() {
    fun canCameraGestureBeLaunched_intentDoesNotResolveToAnyApp_returnsFalse() {
        prepare(installedCameraAppCount = 0)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.KEYGUARD)).isFalse()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is shade - no running tasks - returns true`() {
    fun canCameraGestureBeLaunched_stateIsShade_noRunningTasks_returnsTrue() {
        prepare(isCameraActivityRunningOnTop = false, isTaskListEmpty = true)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.SHADE)).isTrue()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is shade - camera activity on top - returns false`() {
    fun canCameraGestureBeLaunched_stateIsShade_cameraActivityOnTop_returnsFalse() {
        prepare(isCameraActivityRunningOnTop = true)

        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.SHADE)).isFalse()
    }

    @Test
    fun `canCameraGestureBeLaunched - state is shade - camera activity not on top - true`() {
    fun canCameraGestureBeLaunched_stateIsShade_cameraActivityNotOnTop_true() {
        assertThat(underTest.canCameraGestureBeLaunched(StatusBarState.SHADE)).isTrue()
    }

    @Test
    fun `launchCamera - only one camera app installed - using secure screen lock option`() {
    fun launchCamera_onlyOneCameraAppInstalled_usingSecureScreenLockOption() {
        val source = 1337

        underTest.launchCamera(source)
@@ -238,7 +238,7 @@ class CameraGestureHelperTest : SysuiTestCase() {
    }

    @Test
    fun `launchCamera - only one camera app installed - using non-secure screen lock option`() {
    fun launchCamera_onlyOneCameraAppInstalled_usingNonSecureScreenLockOption() {
        prepare(isUsingSecureScreenLockOption = false)
        val source = 1337

@@ -248,7 +248,7 @@ class CameraGestureHelperTest : SysuiTestCase() {
    }

    @Test
    fun `launchCamera - multiple camera apps installed - using secure screen lock option`() {
    fun launchCamera_multipleCameraAppsInstalled_usingSecureScreenLockOption() {
        prepare(installedCameraAppCount = 2)
        val source = 1337

@@ -262,7 +262,7 @@ class CameraGestureHelperTest : SysuiTestCase() {
    }

    @Test
    fun `launchCamera - multiple camera apps installed - using non-secure screen lock option`() {
    fun launchCamera_multipleCameraAppsInstalled_usingNonSecureScreenLockOption() {
        prepare(
            isUsingSecureScreenLockOption = false,
            installedCameraAppCount = 2,
+5 −5
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ class LongPressHandlingViewInteractionHandlerTest : SysuiTestCase() {
    }

    @Test
    fun `long-press`() = runTest {
    fun longPress() = runTest {
        val downX = 123
        val downY = 456
        dispatchTouchEvents(
@@ -91,7 +91,7 @@ class LongPressHandlingViewInteractionHandlerTest : SysuiTestCase() {
    }

    @Test
    fun `long-press but feature not enabled`() = runTest {
    fun longPressButFeatureNotEnabled() = runTest {
        underTest.isLongPressHandlingEnabled = false
        dispatchTouchEvents(
            Down(
@@ -106,7 +106,7 @@ class LongPressHandlingViewInteractionHandlerTest : SysuiTestCase() {
    }

    @Test
    fun `long-press but view not attached`() = runTest {
    fun longPressButViewNotAttached() = runTest {
        isAttachedToWindow = false
        dispatchTouchEvents(
            Down(
@@ -121,7 +121,7 @@ class LongPressHandlingViewInteractionHandlerTest : SysuiTestCase() {
    }

    @Test
    fun `dragged too far to be considered a long-press`() = runTest {
    fun draggedTooFarToBeConsideredAlongPress() = runTest {
        dispatchTouchEvents(
            Down(
                x = 123,
@@ -138,7 +138,7 @@ class LongPressHandlingViewInteractionHandlerTest : SysuiTestCase() {
    }

    @Test
    fun `held down too briefly to be considered a long-press`() = runTest {
    fun heldDownTooBrieflyToBeConsideredAlongPress() = runTest {
        dispatchTouchEvents(
            Down(
                x = 123,
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ class DemoModeControllerTest : SysuiTestCase() {
    }

    @Test
    fun `demo command flow - returns args`() =
    fun demoCommandFlow_returnsArgs() =
        testScope.runTest {
            var latest: Bundle? = null
            val flow = underTest.demoFlowForCommand(TEST_COMMAND)
+6 −6
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ class CustomizationProviderTest : SysuiTestCase() {
    }

    @Test
    fun `onAttachInfo - reportsContext`() {
    fun onAttachInfo_reportsContext() {
        val callback: SystemUIAppComponentFactoryBase.ContextAvailableCallback = mock()
        underTest.setContextAvailableCallback(callback)

@@ -254,7 +254,7 @@ class CustomizationProviderTest : SysuiTestCase() {
    }

    @Test
    fun `insert and query selection`() =
    fun insertAndQuerySelection() =
        testScope.runTest {
            val slotId = KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START
            val affordanceId = AFFORDANCE_2
@@ -278,7 +278,7 @@ class CustomizationProviderTest : SysuiTestCase() {
        }

    @Test
    fun `query slots`() =
    fun querySlotsProvidesTwoSlots() =
        testScope.runTest {
            assertThat(querySlots())
                .isEqualTo(
@@ -296,7 +296,7 @@ class CustomizationProviderTest : SysuiTestCase() {
        }

    @Test
    fun `query affordances`() =
    fun queryAffordancesProvidesTwoAffordances() =
        testScope.runTest {
            assertThat(queryAffordances())
                .isEqualTo(
@@ -316,7 +316,7 @@ class CustomizationProviderTest : SysuiTestCase() {
        }

    @Test
    fun `delete and query selection`() =
    fun deleteAndQuerySelection() =
        testScope.runTest {
            insertSelection(
                slotId = KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
@@ -351,7 +351,7 @@ class CustomizationProviderTest : SysuiTestCase() {
        }

    @Test
    fun `delete all selections in a slot`() =
    fun deleteAllSelectionsInAslot() =
        testScope.runTest {
            insertSelection(
                slotId = KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
Loading