mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 23:32:59 +00:00 
			
		
		
		
	Adjust ExportTest to new DI with FileLocator
This commit is contained in:
		| @@ -21,7 +21,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { | ||||
|     fun exportDatabase(preferences: SharedPreferences, outputPath: String) { | ||||
|         ZipOutputStream(BufferedOutputStream(FileOutputStream(outputPath))) | ||||
|                 .use { outZip -> | ||||
|                     ZipHelper.addFileToZip(outZip, fileLocator.dbDir.path, "newpipe.db") | ||||
|                     ZipHelper.addFileToZip(outZip, fileLocator.db.path, "newpipe.db") | ||||
|  | ||||
|                     try { | ||||
|                         ObjectOutputStream(FileOutputStream(fileLocator.settings)).use { output -> | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package org.schabi.newpipe.settings | ||||
|  | ||||
| import android.content.SharedPreferences | ||||
| import com.nononsenseapps.filepicker.NewFolderFragment | ||||
| import org.junit.Assert | ||||
| import org.junit.Assume | ||||
| import org.junit.Before | ||||
| @@ -24,6 +25,7 @@ class ContentSettingsManagerTest { | ||||
|     class ExportTest { | ||||
|  | ||||
|         companion object { | ||||
|             private lateinit var fileLocator: NewPipeFileLocator | ||||
|             private lateinit var newpipeDb: File | ||||
|             private lateinit var newpipeSettings: File | ||||
|  | ||||
| @@ -37,6 +39,10 @@ class ContentSettingsManagerTest { | ||||
|  | ||||
|                 newpipeDb = File(dbPath!!) | ||||
|                 newpipeSettings = File(settingsPath!!) | ||||
|  | ||||
|                 fileLocator = Mockito.mock(NewPipeFileLocator::class.java, Mockito.withSettings().stubOnly()) | ||||
|                 `when`(fileLocator.db).thenReturn(newpipeDb) | ||||
|                 `when`(fileLocator.settings).thenReturn(newpipeSettings) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -52,7 +58,7 @@ class ContentSettingsManagerTest { | ||||
|             val expectedPreferences = mapOf("such pref" to "much wow") | ||||
|             `when`(preferences.all).thenReturn(expectedPreferences) | ||||
|  | ||||
|             val manager = ContentSettingsManager(newpipeDb, newpipeSettings) | ||||
|             val manager = ContentSettingsManager(fileLocator) | ||||
|  | ||||
|             val output = File.createTempFile("newpipe_", "") | ||||
|             manager.exportDatabase(preferences, output.absolutePath) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 XiangRongLin
					XiangRongLin