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
ConcatAdapterController( | |
ConcatAdapter concatAdapter, | |
ConcatAdapter.Config config | |
) { | |
... | |
if (config.isolateViewTypes) { | |
mViewTypeStorage = new ViewTypeStorage.IsolatedViewTypeStorage(); | |
} else { | |
mViewTypeStorage = new ViewTypeStorage.SharedIdRangeViewTypeStorage(); | |
} |
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
class ConcatAdapterController implements NestedAdapterWrapper.Callback { | |
... | |
private final ViewTypeStorage mViewTypeStorage; | |
... | |
} |
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
class NestedAdapterWrapper { | |
@NonNull | |
private final ViewTypeStorage.ViewTypeLookup mViewTypeLookup; | |
@NonNull | |
private final StableIdStorage.StableIdLookup mStableIdLookup; | |
public final Adapter<ViewHolder> adapter; | |
final Callback mCallback; | |
int mCachedItemCount; |
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
class ConcatAdapterController implements NestedAdapterWrapper.Callback |
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
public static final class Config { | |
public final boolean isolateViewTypes; | |
@NonNull | |
public final StableIdMode stableIdMode; | |
@NonNull | |
public static final Config DEFAULT = new Config(true, NO_STABLE_IDS); | |
} |
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
@Test | |
fun fetchData_loading() { | |
// 메인 디스패처를 게으르게 시작하는 디스패처로 교체 | |
Dispatchers.setMain(StandardTestDispatcher()) | |
// 데이터 가져오기 | |
viewModel.fetch() | |
// 로딩 상태 체크 | |
assertEquals(true, viewModel.loading.getOrAwaitValue()) | |
// 예약되어 있던 작업 실행 | |
advanceUntilIdle() |
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
@Test | |
fun fetchData_loading() { | |
// 메인 디스패처 정지를 위해 pause | |
mainCoroutineRule.pauseDispatcher() | |
// 데이터 가져오기 | |
viewModel.fetch() | |
// 로딩 상태 체크 | |
assertEquals(true, viewModel.loading.getOrAwaitValue()) | |
// 메인 디스패처 다시 시작을 위해 resume | |
mainCoroutineRule.resumeDispatcher() |
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
class MainDispatcherRule( | |
val testDispatcher: TestDispatcher = UnconfinedTestDispatcher() | |
): TestWatcher() { | |
override fun starting(description: Description) { | |
super.starting(description) | |
Dispatchers.setMain(testDispatcher) | |
} | |
override fun finished(description: Description) { |
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
class MainDispatcherRule( | |
val dispatcher = TestCoroutineDispatcher() | |
) : TestWatcher() { | |
override fun starting(description: Description?) { | |
super.starting(description) | |
Dispatchers.setMain(dispatcher) | |
} | |
override fun finished(description: Description?) { |
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
@Test | |
// fun test() = coroutineRule.runBlockingTest { | |
// // Test | |
// } | |
fun test() = runTest { | |
// Test | |
} |