Skip to content

Commit

Permalink
Fix PR review
Browse files Browse the repository at this point in the history
Co-Authored-By: Boban Sijuk <[email protected]>
  • Loading branch information
MaryamShaghaghi and Boki91 committed Dec 1, 2023
1 parent 4864163 commit 5243dde
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FilterScreenTest {
}
composeTestRule.apply {
onNodeWithText("Ownership").performClick()
onNodeWithText("Mullvad owned only").performClick()
onNodeWithText("Mullvad owned only").assertExists()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun FilterCell(
.fillMaxWidth(),
) {
Text(
modifier = Modifier.padding(end = Dimens.filterTittlePadding),
modifier = Modifier.padding(end = Dimens.filterTitlePadding),
text = stringResource(id = R.string.filtered),
color = MaterialTheme.colorScheme.onPrimary,
style = MaterialTheme.typography.labelMedium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import net.mullvad.mullvadvpn.repository.PrivacyDisclaimerRepository
import net.mullvad.mullvadvpn.ui.fragment.AccountFragment
import net.mullvad.mullvadvpn.ui.fragment.ConnectFragment
import net.mullvad.mullvadvpn.ui.fragment.DeviceRevokedFragment
import net.mullvad.mullvadvpn.ui.fragment.FilterFragment
import net.mullvad.mullvadvpn.ui.fragment.LoadingFragment
import net.mullvad.mullvadvpn.ui.fragment.LoginFragment
import net.mullvad.mullvadvpn.ui.fragment.OutOfTimeFragment
Expand Down Expand Up @@ -174,20 +173,6 @@ open class MainActivity : FragmentActivity() {
}
}

fun openFilter() {
supportFragmentManager.beginTransaction().apply {
setCustomAnimations(
R.anim.fragment_enter_from_right,
R.anim.do_nothing,
R.anim.do_nothing,
R.anim.fragment_exit_to_right
)
replace(R.id.main_fragment, FilterFragment())
addToBackStack(null)
commitAllowingStateLoss()
}
}

private fun launchDeviceStateHandler(): Job {
return lifecycleScope.launch {
launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.ui.platform.ComposeView
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.screen.SelectLocationScreen
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.ui.MainActivity
import net.mullvad.mullvadvpn.viewmodel.SelectLocationViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel

Expand All @@ -35,15 +34,25 @@ class SelectLocationFragment : BaseFragment() {
onBackClick = { activity?.onBackPressedDispatcher?.onBackPressed() },
removeOwnershipFilter = vm::removeOwnerFilter,
removeProviderFilter = vm::removeProviderFilter,
onFilterClick = ::openFilterView
onFilterClick = ::openFilter
)
}
}
}
}

private fun openFilterView() {
(context as? MainActivity)?.openFilter()
private fun openFilter() {
parentFragmentManager.beginTransaction().apply {
setCustomAnimations(
R.anim.fragment_enter_from_right,
R.anim.do_nothing,
R.anim.do_nothing,
R.anim.fragment_exit_to_right
)
replace(R.id.main_fragment, FilterFragment())
addToBackStack(null)
commitAllowingStateLoss()
}
}

override fun onEnterTransitionAnimationEnd() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FilterViewModelTest {
private lateinit var viewModel: FilterViewModel
private val selectedOwnership =
MutableStateFlow<Constraint<Ownership>>(Constraint.Only(Ownership.MullvadOwned))
private val mockAllProviders =
private val dummyListOfAllProviders =
listOf(
Provider("31173", true),
Provider("100TB", false),
Expand All @@ -57,7 +57,8 @@ class FilterViewModelTest {
@Before
fun setup() {
every { mockRelayListFilterUseCase.selectedOwnership() } returns selectedOwnership
every { mockRelayListFilterUseCase.availableProviders() } returns flowOf(mockAllProviders)
every { mockRelayListFilterUseCase.availableProviders() } returns
flowOf(dummyListOfAllProviders)
every { mockRelayListFilterUseCase.selectedProviders() } returns
flowOf(Constraint.Only(Providers(mockSelectedProviders.map { it.name }.toHashSet())))
viewModel = FilterViewModel(mockRelayListFilterUseCase)
Expand Down Expand Up @@ -99,7 +100,7 @@ class FilterViewModelTest {
@Test
fun testSetAllProviders() = runTest {
// Arrange
val mockProvidersList = mockAllProviders
val mockProvidersList = dummyListOfAllProviders
// Act
viewModel.setAllProviders(true)
// Assert
Expand All @@ -113,7 +114,8 @@ class FilterViewModelTest {
fun testOnApplyButtonClicked() = runTest {
// Arrange
val mockOwnership = Ownership.MullvadOwned.toOwnershipConstraint()
val mockSelectedProviders = mockSelectedProviders.toConstraintProviders(mockAllProviders)
val mockSelectedProviders =
mockSelectedProviders.toConstraintProviders(dummyListOfAllProviders)
// Act
viewModel.onApplyButtonClicked()
// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class Dimensions(
val dialogIconHeight: Dp = 44.dp,
val dialogIconSize: Dp = 48.dp,
val expandableCellChevronSize: Dp = 30.dp,
val filterTittlePadding: Dp = 4.dp,
val filterTitlePadding: Dp = 4.dp,
val iconFailSuccessTopMargin: Dp = 30.dp,
val iconHeight: Dp = 44.dp,
val indentedCellStartPadding: Dp = 38.dp,
Expand Down

0 comments on commit 5243dde

Please sign in to comment.