-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add AndroidSchedulers.reset() for better testing support #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
192da26
ca2bf94
da5675c
bf5c11d
92bda7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package rx.android.schedulers; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import rx.Scheduler; | ||
import rx.android.plugins.RxAndroidPlugins; | ||
import rx.android.plugins.RxAndroidSchedulersHook; | ||
import rx.schedulers.TestScheduler; | ||
|
||
import static org.junit.Assert.assertSame; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public final class ResetSchedulersTest { | ||
|
||
@Test | ||
public void reset() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only other test using Robolectric was |
||
RxAndroidPlugins.getInstance().reset(); | ||
|
||
final TestScheduler testScheduler = new TestScheduler(); | ||
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() { | ||
@Override | ||
public Scheduler getMainThreadScheduler() { | ||
return testScheduler; | ||
} | ||
}); | ||
AndroidSchedulers.reset(); | ||
|
||
assertSame(AndroidSchedulers.mainThread(), testScheduler); | ||
|
||
RxAndroidPlugins.getInstance().reset(); | ||
RxAndroidPlugins.getInstance().registerSchedulersHook(RxAndroidSchedulersHook.getDefaultInstance()); | ||
AndroidSchedulers.reset(); | ||
|
||
assertTrue(AndroidSchedulers.mainThread() instanceof LooperScheduler); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bf5c11d