mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 06:47:03 +03:00
#1170 Fix unit tests
This commit is contained in:
parent
d40f5dfa76
commit
bf836f98e2
4 changed files with 45 additions and 193 deletions
|
@ -134,21 +134,21 @@ public class NotesRepository {
|
|||
|
||||
public static synchronized NotesRepository getInstance(@NonNull Context context) {
|
||||
if (instance == null) {
|
||||
instance = new NotesRepository(context);
|
||||
instance = new NotesRepository(context, NotesDatabase.getInstance(context.getApplicationContext()));
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private NotesRepository(final Context context) {
|
||||
private NotesRepository(@NonNull final Context context, @NonNull final NotesDatabase db) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.db = NotesDatabase.getInstance(this.context);
|
||||
this.db = db;
|
||||
this.defaultNonEmptyTitle = NoteUtil.generateNonEmptyNoteTitle("", this.context);
|
||||
this.syncOnlyOnWifiKey = context.getApplicationContext().getResources().getString(R.string.pref_key_wifi_only);
|
||||
|
||||
// Registers BroadcastReceiver to track network connection changes.
|
||||
context.getApplicationContext().registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context.getApplicationContext());
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context.getApplicationContext());
|
||||
prefs.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
|
||||
syncOnlyOnWifi = prefs.getBoolean(syncOnlyOnWifiKey, false);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class NotesDaoTest {
|
|||
.inMemoryDatabaseBuilder(ApplicationProvider.getApplicationContext(), NotesDatabase.class)
|
||||
.allowMainThreadQueries()
|
||||
.build();
|
||||
db.addAccount("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", new Capabilities("{ocs: {}}", null));
|
||||
db.getAccountDao().insert(new Account("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", new Capabilities("{ocs: {}}", null)));
|
||||
account = db.getAccountDao().getAccountByName("彼得@äöüß.example.com");
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ public class NotesDaoTest {
|
|||
}
|
||||
|
||||
private Account setupSecondAccount() throws NextcloudHttpRequestFailedException {
|
||||
db.addAccount("https://example.org", "test", "test@example.org", new Capabilities("{ocs: {}}", null));
|
||||
db.getAccountDao().insert(new Account("https://example.org", "test", "test@example.org", new Capabilities("{ocs: {}}", null)));
|
||||
return db.getAccountDao().getAccountByName("test@example.org");
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue