[fenix] For https://github.com/mozilla-mobile/fenix/issues/18520: Add Empty Tab State To Browser Tray List
parent
d57bcda8ef
commit
68b17ba7e8
@ -1,6 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<org.mozilla.fenix.tabstray.browser.NormalBrowserTrayList
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/tray_list_item"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.mozilla.fenix.tabstray.browser.NormalBrowserTrayList
|
||||||
|
android:id="@+id/tray_list_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tab_tray_empty_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingTop="80dp"
|
||||||
|
android:text="@string/no_open_tabs_description"
|
||||||
|
android:textColor="?secondaryText"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:visibility="visible" />
|
||||||
|
</FrameLayout>
|
||||||
|
@ -1,6 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<org.mozilla.fenix.tabstray.browser.PrivateBrowserTrayList
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/tray_list_item"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.mozilla.fenix.tabstray.browser.PrivateBrowserTrayList
|
||||||
|
android:id="@+id/tray_list_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tab_tray_empty_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingTop="80dp"
|
||||||
|
android:text="@string/no_open_tabs_description"
|
||||||
|
android:textColor="?secondaryText"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:visibility="visible" />
|
||||||
|
</FrameLayout>
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
/* 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.fenix.tabstray.viewholders
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import io.mockk.mockk
|
||||||
|
import mozilla.components.concept.tabstray.Tabs
|
||||||
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||||
|
import org.mozilla.fenix.tabstray.TabsTrayStore
|
||||||
|
import org.mozilla.fenix.tabstray.browser.BaseBrowserTrayList
|
||||||
|
import org.mozilla.fenix.tabstray.browser.BrowserTabsAdapter
|
||||||
|
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
|
||||||
|
import org.mozilla.fenix.tabstray.browser.createTab
|
||||||
|
|
||||||
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
|
class BaseBrowserTabViewHolderTest {
|
||||||
|
val store: TabsTrayStore = TabsTrayStore()
|
||||||
|
val interactor = mockk<TabsTrayInteractor>(relaxed = true)
|
||||||
|
val browserTrayInteractor = mockk<BrowserTrayInteractor>(relaxed = true)
|
||||||
|
val adapter = BrowserTabsAdapter(testContext, browserTrayInteractor, store)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `WHEN tabs inserted THEN show tray`() {
|
||||||
|
val itemView =
|
||||||
|
LayoutInflater.from(testContext).inflate(R.layout.normal_browser_tray_list, null)
|
||||||
|
val viewHolder = NormalBrowserTabViewHolder(itemView, store, interactor, 5)
|
||||||
|
val trayList: BaseBrowserTrayList = itemView.findViewById(R.id.tray_list_item)
|
||||||
|
val emptyList: TextView = itemView.findViewById(R.id.tab_tray_empty_view)
|
||||||
|
|
||||||
|
viewHolder.bind(adapter, LinearLayoutManager(testContext))
|
||||||
|
|
||||||
|
adapter.updateTabs(
|
||||||
|
Tabs(
|
||||||
|
list = listOf(
|
||||||
|
createTab("tab1")
|
||||||
|
),
|
||||||
|
selectedIndex = 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
adapter.onTabsInserted(0, 1)
|
||||||
|
|
||||||
|
assertTrue(trayList.visibility == VISIBLE)
|
||||||
|
assertTrue(emptyList.visibility == GONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `WHEN no tabs THEN show empty view`() {
|
||||||
|
val itemView =
|
||||||
|
LayoutInflater.from(testContext).inflate(R.layout.normal_browser_tray_list, null)
|
||||||
|
val viewHolder = NormalBrowserTabViewHolder(itemView, store, interactor, 5)
|
||||||
|
val trayList: BaseBrowserTrayList = itemView.findViewById(R.id.tray_list_item)
|
||||||
|
val emptyList: TextView = itemView.findViewById(R.id.tab_tray_empty_view)
|
||||||
|
|
||||||
|
viewHolder.bind(adapter, LinearLayoutManager(testContext))
|
||||||
|
|
||||||
|
adapter.updateTabs(
|
||||||
|
Tabs(
|
||||||
|
list = emptyList(),
|
||||||
|
selectedIndex = 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
adapter.onTabsInserted(0, 0)
|
||||||
|
|
||||||
|
assertTrue(trayList.visibility == GONE)
|
||||||
|
assertTrue(emptyList.visibility == VISIBLE)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue