forked from mozilla-mobile/firefox-tv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue mozilla-mobile#2805: Add MockWebBackForwardList.
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
app/src/testSystem/java/org/mozilla/tv/firefox/helpers/MockWebBackForwardList.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.tv.firefox.helpers | ||
|
||
import android.graphics.Bitmap | ||
import android.webkit.WebBackForwardList | ||
import android.webkit.WebHistoryItem | ||
|
||
/** | ||
* An implementation of the [WebBackForwardList] abstract class for testing. | ||
*/ | ||
class MockWebBackForwardList( | ||
private val backingList: List<WebHistoryItem>, | ||
private val mockCurrentIndex: Int = 0 | ||
) : WebBackForwardList() { | ||
|
||
override fun getSize(): Int = backingList.size | ||
override fun getItemAtIndex(index: Int): WebHistoryItem = backingList[index] | ||
|
||
override fun getCurrentIndex(): Int = mockCurrentIndex | ||
override fun getCurrentItem(): WebHistoryItem? = backingList[mockCurrentIndex] | ||
|
||
override fun clone(): WebBackForwardList { | ||
TODO("not implemented: not needed yet") | ||
} | ||
} | ||
|
||
/** | ||
* An implementation of the [WebHistoryItem] abstract class for testing. | ||
*/ | ||
class MockWebHistoryItem( | ||
private val mockOriginalUrl: String? = null | ||
) : WebHistoryItem() { | ||
|
||
override fun getOriginalUrl(): String? = mockOriginalUrl | ||
|
||
override fun getUrl(): String? { | ||
TODO("not implemented: not needed yet") | ||
} | ||
|
||
override fun getFavicon(): Bitmap? { | ||
TODO("not implemented: not needed yet") | ||
} | ||
|
||
override fun getTitle(): String? { | ||
TODO("not implemented: not needed yet") | ||
} | ||
|
||
override fun clone(): WebHistoryItem { | ||
TODO("not implemented: not needed yet") | ||
} | ||
} | ||
|
||
fun List<WebHistoryItem>.toMockWebBackForwardList(): MockWebBackForwardList { | ||
return MockWebBackForwardList(this) | ||
} |