@Test
public void asObservableHonorsBackpressure() {

    Preference<String> preference = rxPreferences.getString("key1", "defValue");
    TestSubscriber<String> o = new TestSubscriber<>(2);
    preference.asObservable().subscribe(o);
    o.assertValues("defValue");
    rxPreferences.putString("key1", "value1");
    o.assertValues("defValue", "value1");
    rxPreferences.putString("key1", "value2");
    o.assertValues("defValue", "value1"); // No new item due to backpressure.
    o.requestMore(1);
    o.assertValues("defValue", "value1", "value2");
    for (int i = 0; i < 1000; i++) {
        rxPreferences.putString("key1", "value" + i);
    }
    o.assertValues("defValue", "value1", "value2"); // No new items due to backpressure.
    o.requestMore(Long.MAX_VALUE);
    o.assertValues("defValue", "value1", "value2", "value999"); // only latest.
}