diff --git a/core-ui/build.gradle b/core-ui/build.gradle index a668034c84..e398ab310d 100644 --- a/core-ui/build.gradle +++ b/core-ui/build.gradle @@ -11,7 +11,7 @@ android { targetSdkVersion config["target_sdk"] testInstrumentationRunner config["test_runner"] buildConfigField "boolean", "USE_NEW_WINDOW_INSET_API", "true" - buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "false" + buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true" } testOptions { diff --git a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockAdapterTest.kt b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockAdapterTest.kt index 137eb54873..06859f8f17 100644 --- a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockAdapterTest.kt +++ b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockAdapterTest.kt @@ -262,13 +262,15 @@ class BlockAdapterTest { // Setup - val paragraph = BlockView.Text.Paragraph( - text = MockDataFactory.randomString(), - id = MockDataFactory.randomUuid() - ) + val paragraph = StubParagraphView() val updated = paragraph.copy( - background = ThemeColor.PURPLE + background = ThemeColor.PURPLE, + decorations = listOf( + BlockView.Decoration( + background = ThemeColor.PURPLE + ) + ) ) val views = listOf(paragraph) @@ -306,11 +308,13 @@ class BlockAdapterTest { onSlashEvent = {} ) - val expected = context.resources.getColor(R.color.palette_very_light_purple) - assertEquals( - expected = expected, - actual = (holder.root.background as ColorDrawable).color - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val expected = context.resources.getColor(R.color.palette_very_light_purple) + assertEquals( + expected = expected, + actual = (holder.root.background as ColorDrawable).color + ) + } } @Test @@ -823,14 +827,15 @@ class BlockAdapterTest { check(holder is Paragraph) - val actual = holder.content.paddingLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.content.paddingLeft - val expected = - holder.dimen(R.dimen.default_document_content_padding_start) + paragraph.indent * holder.dimen( - R.dimen.indent - ) - - assertEquals(expected, actual) + val expected = + holder.dimen(R.dimen.default_document_content_padding_start) + paragraph.indent * holder.dimen( + R.dimen.indent + ) + assertEquals(expected, actual) + } } @Test @@ -856,14 +861,14 @@ class BlockAdapterTest { check(holder is HeaderOne) - val actual = holder.content.paddingLeft - - val expected = - holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( - R.dimen.indent - ) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.content.paddingLeft + val expected = + holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) + assertEquals(expected, actual) + } } @Test @@ -889,14 +894,16 @@ class BlockAdapterTest { check(holder is HeaderTwo) - val actual = holder.content.paddingLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.content.paddingLeft - val expected = - holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( - R.dimen.indent - ) + val expected = + holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test @@ -922,25 +929,22 @@ class BlockAdapterTest { check(holder is HeaderThree) - val actual = holder.content.paddingLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.content.paddingLeft - val expected = - holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( - R.dimen.indent - ) + val expected = + holder.dimen(R.dimen.default_document_content_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test fun `should apply indent to checkbox view`() { - val view = BlockView.Text.Checkbox( - id = MockDataFactory.randomUuid(), - text = MockDataFactory.randomString(), - indent = MockDataFactory.randomInt() - ) - + val view = StubCheckboxView() val views = listOf(view) val recycler = RecyclerView(context).apply { @@ -955,11 +959,11 @@ class BlockAdapterTest { check(holder is Checkbox) - val actual = holder.itemView.findViewById(R.id.checkboxIcon).paddingLeft - - val expected = view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.findViewById(R.id.checkboxIcon).paddingLeft + val expected = view.indent * holder.dimen(R.dimen.indent) + assertEquals(expected, actual) + } } @Test @@ -988,22 +992,20 @@ class BlockAdapterTest { check(holder is Toggle) - val actual = - (holder.itemView.findViewById(R.id.guideline).layoutParams as ConstraintLayout.LayoutParams).guideBegin + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = + (holder.itemView.findViewById(R.id.guideline).layoutParams as ConstraintLayout.LayoutParams).guideBegin - val expected = view.indent * holder.dimen(R.dimen.indent) + val expected = view.indent * holder.dimen(R.dimen.indent) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test fun `should apply indent to file placeholder view`() { - val view = BlockView.MediaPlaceholder.File( - id = MockDataFactory.randomUuid(), - indent = MockDataFactory.randomInt(), - isPreviousBlockMedia = false - ) + val view = StubFilePlaceholderView() val views = listOf(view) @@ -1019,12 +1021,14 @@ class BlockAdapterTest { check(holder is FilePlaceholder) - val actual = holder.itemView.paddingLeft - - val expected = - holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.paddingLeft + val expected = + holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) + assertEquals(expected, actual) + } } @Test @@ -1050,11 +1054,11 @@ class BlockAdapterTest { check(holder is FileError) - val actual = holder.itemView.marginLeft - - val expected = view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft + val expected = view.indent * holder.dimen(R.dimen.indent) + assertEquals(expected, actual) + } } @Test @@ -1079,12 +1083,12 @@ class BlockAdapterTest { check(holder is FileUpload) - val actual = holder.itemView.marginLeft - - val expected = - holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft + val expected = + holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) + assertEquals(expected, actual) + } } @Test @@ -1117,11 +1121,7 @@ class BlockAdapterTest { @Test fun `should apply indent to video placeholder view`() { - val view = BlockView.MediaPlaceholder.Video( - id = MockDataFactory.randomUuid(), - indent = MockDataFactory.randomInt(), - isPreviousBlockMedia = false - ) + val view = StubVideoPlaceholderView() val views = listOf(view) @@ -1137,12 +1137,14 @@ class BlockAdapterTest { check(holder is VideoPlaceholder) - val actual = holder.itemView.paddingLeft - - val expected = - holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.paddingLeft + val expected = + holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) + assertEquals(expected, actual) + } } @Test @@ -1167,12 +1169,14 @@ class BlockAdapterTest { check(holder is VideoUpload) - val actual = holder.itemView.marginLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft - val expected = - holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) + val expected = + holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test @@ -1198,11 +1202,13 @@ class BlockAdapterTest { check(holder is VideoError) - val actual = holder.itemView.marginLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft - val expected = view.indent * holder.dimen(R.dimen.indent) + val expected = view.indent * holder.dimen(R.dimen.indent) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test @@ -1228,56 +1234,17 @@ class BlockAdapterTest { check(holder is LinkToObject) - val actual = holder.itemView.marginLeft - - val expected = view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft + val expected = view.indent * holder.dimen(R.dimen.indent) + assertEquals(expected, actual) + } } -// Turned off the test, because Robolectric is not working with MateralCardView -// @Test -// fun `should apply indent to bookmark view`() { -// -// val view = BlockView.Bookmark.View( -// id = MockDataFactory.randomUuid(), -// indent = MockDataFactory.randomInt(), -// description = MockDataFactory.randomString(), -// title = MockDataFactory.randomString(), -// faviconUrl = MockDataFactory.randomString(), -// imageUrl = MockDataFactory.randomString(), -// url = MockDataFactory.randomString() -// ) -// -// val views = listOf(view) -// -// val recycler = RecyclerView(context).apply { -// layoutManager = LinearLayoutManager(context) -// } -// -// val adapter = buildAdapter(views) -// -// val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK) -// -// adapter.bindViewHolder(holder, 0) -// -// check(holder is Types.Bookmark) -// -// val actual = (holder.itemView.bookmarkRoot).marginLeft -// -// val expected = view.indent * holder.dimen(R.dimen.indent) + holder.dimen(R.dimen.dp_12) -// -// assertEquals(expected, actual) -// } - @Test fun `should apply indent to bookmark placeholder view`() { - val view = BlockView.MediaPlaceholder.Bookmark( - id = MockDataFactory.randomUuid(), - indent = MockDataFactory.randomInt(), - isPreviousBlockMedia = false - ) + val view = StubBookmarkPlaceholderView() val views = listOf(view) @@ -1287,19 +1254,21 @@ class BlockAdapterTest { val adapter = buildAdapter(views) - val holder = - adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK_PLACEHOLDER) + val holder = adapter.onCreateViewHolder(recycler, Types.HOLDER_BOOKMARK_PLACEHOLDER) adapter.bindViewHolder(holder, 0) check(holder is BookmarkPlaceholder) - val actual = holder.itemView.findViewById(R.id.root).paddingLeft - - val expected = - view.indent * holder.dimen(R.dimen.indent) + holder.dimen(R.dimen.default_document_item_padding_start) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.findViewById(R.id.root).paddingLeft + val expected = view.indent * holder.dimen(R.dimen.indent) + holder.dimen(R.dimen.default_document_item_padding_start) + assertEquals(expected, actual) + } else { + val actual = holder.itemView.findViewById(R.id.root).paddingLeft + val expected = 0 + assertEquals(expected, actual) + } } @Test @@ -1330,22 +1299,20 @@ class BlockAdapterTest { check(holder is Picture) - val actual = holder.itemView.marginLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft - val expected = - holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) + val expected = + holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test fun `should apply indent to picture placeholder view`() { - val view = BlockView.MediaPlaceholder.Picture( - id = MockDataFactory.randomUuid(), - indent = MockDataFactory.randomInt(), - isPreviousBlockMedia = false - ) + val view = StubPicturePlaceholderView() val views = listOf(view) @@ -1361,11 +1328,14 @@ class BlockAdapterTest { check(holder is PicturePlaceholder) - val actual = holder.itemView.paddingLeft - - val expected = holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.paddingLeft + val expected = + holder.dimen(R.dimen.default_document_item_padding_start) + view.indent * holder.dimen( + R.dimen.indent + ) + assertEquals(expected, actual) + } } @Test @@ -1391,11 +1361,13 @@ class BlockAdapterTest { check(holder is PictureError) - val actual = holder.itemView.marginLeft + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft - val expected = view.indent * holder.dimen(R.dimen.indent) + val expected = view.indent * holder.dimen(R.dimen.indent) - assertEquals(expected, actual) + assertEquals(expected, actual) + } } @Test @@ -1420,12 +1392,11 @@ class BlockAdapterTest { check(holder is PictureUpload) - val actual = holder.itemView.marginLeft - - val expected = - holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) - - assertEquals(expected, actual) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + val actual = holder.itemView.marginLeft + val expected = holder.dimen(R.dimen.bookmark_default_margin_start) + view.indent * holder.dimen(R.dimen.indent) + assertEquals(expected, actual) + } } //@Test diff --git a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockViewStubs.kt b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockViewStubs.kt index 0a187863cf..2635a516dc 100644 --- a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockViewStubs.kt +++ b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/BlockViewStubs.kt @@ -20,7 +20,13 @@ fun StubParagraphView( searchFields: List = emptyList(), backgroundColor: ThemeColor = ThemeColor.DEFAULT, mode: BlockView.Mode = BlockView.Mode.EDIT, - decorations: List = emptyList(), + decorations: List = if (BuildConfig.NESTED_DECORATION_ENABLED) + listOf( + BlockView.Decoration( + background = backgroundColor + ) + ) else + emptyList(), ghostSelection: IntRange? = null, cursor: Int? = null, alignment: Alignment? = null @@ -207,4 +213,92 @@ fun StubCalloutView( ghostEditorSelection = ghostSelection, cursor = cursor, icon = icon +) + +fun StubBookmarkPlaceholderView( + id: Id = MockDataFactory.randomUuid(), + indent: Indent = MockDataFactory.randomInt(), + isPreviousBlockMedia: Boolean = false, + background: ThemeColor = ThemeColor.DEFAULT, + decorations: List = if (BuildConfig.NESTED_DECORATION_ENABLED) + listOf( + BlockView.Decoration( + style = BlockView.Decoration.Style.Card, + background = background + ) + ) + else + emptyList() +): BlockView.MediaPlaceholder.Bookmark = BlockView.MediaPlaceholder.Bookmark( + id = id, + indent = indent, + isPreviousBlockMedia = isPreviousBlockMedia, + background = background, + decorations = decorations +) + +fun StubPicturePlaceholderView( + id: Id = MockDataFactory.randomUuid(), + indent: Indent = MockDataFactory.randomInt(), + isPreviousBlockMedia: Boolean = false, + background: ThemeColor = ThemeColor.DEFAULT, + decorations: List = if (BuildConfig.NESTED_DECORATION_ENABLED) + listOf( + BlockView.Decoration( + style = BlockView.Decoration.Style.Card, + background = background + ) + ) + else + emptyList() +): BlockView.MediaPlaceholder.Picture = BlockView.MediaPlaceholder.Picture( + id = id, + indent = indent, + isPreviousBlockMedia = isPreviousBlockMedia, + background = background, + decorations = decorations +) + +fun StubVideoPlaceholderView( + id: Id = MockDataFactory.randomUuid(), + indent: Indent = MockDataFactory.randomInt(), + isPreviousBlockMedia: Boolean = false, + background: ThemeColor = ThemeColor.DEFAULT, + decorations: List = if (BuildConfig.NESTED_DECORATION_ENABLED) + listOf( + BlockView.Decoration( + style = BlockView.Decoration.Style.Card, + background = background + ) + ) + else + emptyList() +): BlockView.MediaPlaceholder.Video = BlockView.MediaPlaceholder.Video( + id = id, + indent = indent, + isPreviousBlockMedia = isPreviousBlockMedia, + background = background, + decorations = decorations +) + +fun StubFilePlaceholderView( + id: Id = MockDataFactory.randomUuid(), + indent: Indent = MockDataFactory.randomInt(), + isPreviousBlockMedia: Boolean = false, + background: ThemeColor = ThemeColor.DEFAULT, + decorations: List = if (BuildConfig.NESTED_DECORATION_ENABLED) + listOf( + BlockView.Decoration( + style = BlockView.Decoration.Style.Card, + background = background + ) + ) + else + emptyList() +): BlockView.MediaPlaceholder.File = BlockView.MediaPlaceholder.File( + id = id, + indent = indent, + isPreviousBlockMedia = isPreviousBlockMedia, + background = background, + decorations = decorations ) \ No newline at end of file diff --git a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapterIndentationTest.kt b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapterIndentationTest.kt index d748f9c670..93f047562b 100644 --- a/core-ui/src/test/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapterIndentationTest.kt +++ b/core-ui/src/test/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapterIndentationTest.kt @@ -4,7 +4,9 @@ import android.os.Build import androidx.core.view.marginLeft import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.anytypeio.anytype.core_ui.BuildConfig import com.anytypeio.anytype.core_ui.R +import com.anytypeio.anytype.core_ui.StubParagraphView import com.anytypeio.anytype.core_ui.features.editor.holders.text.* import com.anytypeio.anytype.core_utils.ext.dimen import com.anytypeio.anytype.presentation.editor.editor.model.BlockView @@ -33,11 +35,7 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { val padding = context.dimen(R.dimen.default_document_content_padding_start).toInt() val indent = context.dimen(R.dimen.indent) - val block = BlockView.Text.Paragraph( - id = MockDataFactory.randomUuid(), - text = MockDataFactory.randomString(), - indent = 0 - ) + val block = StubParagraphView(indent = 0) val views = listOf(block) @@ -72,10 +70,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.content.paddingLeft, - expected = padding + (indent.toInt() * 2) - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.content.paddingLeft, + expected = padding + (indent.toInt() * 2) + ) + } } @Test @@ -125,10 +125,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.content.paddingLeft, - expected = padding + (indent.toInt() * 2) - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.content.paddingLeft, + expected = padding + (indent.toInt() * 2) + ) + } } @Test @@ -178,10 +180,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.content.paddingLeft, - expected = padding + (indent.toInt() * 2) - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.content.paddingLeft, + expected = padding + (indent.toInt() * 2) + ) + } } @Test @@ -231,10 +235,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.content.paddingLeft, - expected = padding + (indent.toInt() * 2) - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.content.paddingLeft, + expected = padding + (indent.toInt() * 2) + ) + } } @Test @@ -283,10 +289,12 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.checkbox.paddingLeft, - expected = indent.toInt() * 2 - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.checkbox.paddingLeft, + expected = indent.toInt() * 2 + ) + } } @Test @@ -336,9 +344,11 @@ class BlockAdapterIndentationTest : BlockAdapterTestSetup() { adapter.onBindViewHolder(holder, 0, payloads = payload) - assertEquals( - actual = holder.number.marginLeft, - expected = indent.toInt() * 2 - ) + if (!BuildConfig.NESTED_DECORATION_ENABLED) { + assertEquals( + actual = holder.number.marginLeft, + expected = indent.toInt() * 2 + ) + } } } \ No newline at end of file diff --git a/presentation/build.gradle b/presentation/build.gradle index 4d1affe8ef..bc2ba73c3b 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -12,7 +12,7 @@ android { targetSdkVersion config["target_sdk"] testInstrumentationRunner config["test_runner"] buildConfigField "boolean", "ENABLE_LINK_APPERANCE_MENU", "true" - buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "false" + buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "true" } testOptions.unitTests.includeAndroidResources = true diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt index f8eb5241f0..8e4cf9ae54 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/BlockReadModeTest.kt @@ -4,11 +4,13 @@ import android.os.Build import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig.NESTED_DECORATION_ENABLED import com.anytypeio.anytype.presentation.editor.editor.BlockDimensions import com.anytypeio.anytype.presentation.editor.editor.ViewState import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test @@ -82,7 +84,16 @@ class BlockReadModeTest : EditorViewModelTest() { id = p.id, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, blocks[1].let { p -> @@ -91,7 +102,16 @@ class BlockReadModeTest : EditorViewModelTest() { marks = emptyList(), text = p.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -102,7 +122,16 @@ class BlockReadModeTest : EditorViewModelTest() { id = p.id, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, blocks[1].let { p -> @@ -110,7 +139,16 @@ class BlockReadModeTest : EditorViewModelTest() { id = p.id, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -119,7 +157,7 @@ class BlockReadModeTest : EditorViewModelTest() { id = title.id, text = title.content().text, isFocused = false, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, ) private val titleReadModeView = BlockView.Title.Basic( @@ -173,7 +211,16 @@ class BlockReadModeTest : EditorViewModelTest() { id = p.id, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, blocks[1].let { p -> @@ -182,7 +229,16 @@ class BlockReadModeTest : EditorViewModelTest() { marks = emptyList(), text = p.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -257,7 +313,16 @@ class BlockReadModeTest : EditorViewModelTest() { id = p.id, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, blocks[1].let { p -> @@ -266,7 +331,16 @@ class BlockReadModeTest : EditorViewModelTest() { isSelected = true, marks = emptyList(), text = p.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DefaultBlockViewRendererTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DefaultBlockViewRendererTest.kt index 7ce1d1ac91..223dc6cd21 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DefaultBlockViewRendererTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/DefaultBlockViewRendererTest.kt @@ -2771,6 +2771,16 @@ class DefaultBlockViewRendererTest { background = a.parseThemeBackgroundColor(), isPreviousBlockMedia = false, objectTypeName = null, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Card + ) + ) + } else { + emptyList() + } ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt index 347e16c5a8..5c3717c422 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/EditorViewModelTest.kt @@ -10,6 +10,8 @@ import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_models.Position import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.core_models.SmartBlockType +import com.anytypeio.anytype.core_models.StubFile +import com.anytypeio.anytype.core_models.StubParagraph import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction import com.anytypeio.anytype.core_utils.common.EventWrapper @@ -391,16 +393,7 @@ open class EditorViewModelTest { val child = MockDataFactory.randomUuid() - val paragraph = Block( - id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() - ) + val paragraph = StubParagraph(id = child) val page = listOf( Block( @@ -441,7 +434,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -576,15 +578,8 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val child = MockDataFactory.randomUuid() - val paragraph = Block( - id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() + val paragraph = StubParagraph( + id = child ) val page = listOf( @@ -599,16 +594,7 @@ open class EditorViewModelTest { paragraph ) - val added = Block( - id = MockDataFactory.randomUuid(), - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() - ) + val added = StubParagraph() stubObserveEvents( flow { @@ -660,12 +646,30 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content.asText().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = added.id, text = added.content.asText().text, - background = added.parseThemeBackgroundColor() + background = added.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = added.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -729,16 +733,7 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val child = MockDataFactory.randomUuid() - val paragraph = Block( - id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() - ) + val paragraph = StubParagraph(id = child) val page = listOf( Block( @@ -796,7 +791,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content.asText().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -917,7 +921,16 @@ open class EditorViewModelTest { from = firstTimeRange.first(), to = firstTimeRange.last() ) - ) + ), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -959,7 +972,16 @@ open class EditorViewModelTest { from = secondTimeRange.first(), to = secondTimeRange.last() ) - ) + ), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1057,7 +1079,16 @@ open class EditorViewModelTest { from = firstTimeRange.first(), to = firstTimeRange.last() ) - ) + ), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1102,7 +1133,16 @@ open class EditorViewModelTest { from = secondTimeRange.first(), to = secondTimeRange.last() ) - ) + ), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1119,17 +1159,10 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val child = MockDataFactory.randomUuid() - val paragraph = Block( + val paragraph = StubParagraph( id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P, - color = "red" - ), - children = emptyList(), - backgroundColor = "yellow" + textColor = ThemeColor.RED.code, + backgroundColor = ThemeColor.YELLOW.code ) val page = Block( @@ -1210,16 +1243,7 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val child = MockDataFactory.randomUuid() - val paragraph = Block( - id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() - ) + val paragraph = StubParagraph(id = child) val page = Block( id = root, @@ -1271,7 +1295,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content.asText().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1507,16 +1540,7 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val child = MockDataFactory.randomUuid() - val paragraph = Block( - id = child, - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() - ) + val paragraph = StubParagraph(id = child) val page = Block( id = root, @@ -1591,7 +1615,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1610,13 +1643,32 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = paragraph.id, text = paragraph.content().text, - background = paragraph.parseThemeBackgroundColor() + background = paragraph.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.One( id = new.id, text = new.content().text, background = new.parseThemeBackgroundColor(), - indent = 0 + indent = 0, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = new.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ) ) ) @@ -1753,26 +1805,12 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() - val firstChild = Block( - id = "FIRST CHILD", - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = "FIRST CHILD TEXT", - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() + val firstChild = StubParagraph( + id = "FIRST CHILD" ) - val secondChild = Block( - id = "SECOND CHILD", - fields = Block.Fields(emptyMap()), - content = Block.Content.Text( - text = "SECOND CHILD TEXT", - marks = emptyList(), - style = Block.Content.Text.Style.P - ), - children = emptyList() + val secondChild = StubParagraph( + id = "SECOND CHILD" ) val page = Block( @@ -1828,12 +1866,30 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = firstChild.id, text = firstChild.content().text, - background = firstChild.parseThemeBackgroundColor() + background = firstChild.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = firstChild.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = secondChild.id, text = secondChild.content().text, - background = secondChild.parseThemeBackgroundColor() + background = secondChild.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = secondChild.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1862,7 +1918,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = secondChild.id, text = secondChild.content().text, - background = secondChild.parseThemeBackgroundColor() + background = secondChild.parseThemeBackgroundColor(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = secondChild.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -3082,36 +3147,9 @@ open class EditorViewModelTest { // SETUP val paragraphs = listOf( - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + StubParagraph(), + StubParagraph(), + StubParagraph() ) val page = listOf( @@ -3159,21 +3197,48 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[1].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[2].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -3254,7 +3319,7 @@ open class EditorViewModelTest { vm.onTextInputClicked(target = paragraphs[2].id) - // At this momemnt, we expect that all blocks are unselected, therefore we should exit to read mode. + // At this moment, we expect that all blocks are unselected, therefore we should exit to read mode. coroutineTestRule.advanceTime(EditorViewModel.DELAY_REFRESH_DOCUMENT_ON_EXIT_MULTI_SELECT_MODE) @@ -3268,18 +3333,7 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() - val paragraphs = listOf( - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ) - ) + val paragraphs = listOf(StubParagraph()) val page = listOf( Block( @@ -3326,7 +3380,16 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -3419,7 +3482,7 @@ open class EditorViewModelTest { listOf( BlockView.Decoration( background = ThemeColor.DEFAULT, - style = BlockView.Decoration.Style.None + style = BlockView.Decoration.Style.Card ) ) } else { @@ -3498,7 +3561,7 @@ open class EditorViewModelTest { listOf( BlockView.Decoration( background = ThemeColor.DEFAULT, - style = BlockView.Decoration.Style.None + style = BlockView.Decoration.Style.Card ) ) } else { @@ -3527,15 +3590,9 @@ open class EditorViewModelTest { @Test fun `open select file - when error in edit mode`() { - val file = Block( - id = MockDataFactory.randomUuid(), - fields = Block.Fields(emptyMap()), - content = Block.Content.File( - hash = MockDataFactory.randomString(), - type = Block.Content.File.Type.FILE, - state = Block.Content.File.State.ERROR - ), - children = emptyList() + val file = StubFile( + state = Block.Content.File.State.ERROR, + type = Block.Content.File.Type.FILE, ) val page = listOf( @@ -3578,7 +3635,7 @@ open class EditorViewModelTest { listOf( BlockView.Decoration( background = ThemeColor.DEFAULT, - style = BlockView.Decoration.Style.None + style = BlockView.Decoration.Style.Card ) ) } else { @@ -3884,36 +3941,9 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val paragraphs = listOf( - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + StubParagraph(), + StubParagraph(), + StubParagraph() ) val page = listOf( @@ -3961,21 +3991,48 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[1].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[2].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -3999,36 +4056,9 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() val paragraphs = listOf( - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + StubParagraph(), + StubParagraph(), + StubParagraph() ) val page = listOf( @@ -4076,21 +4106,48 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[1].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[2].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) @@ -4121,38 +4178,7 @@ open class EditorViewModelTest { val root = MockDataFactory.randomUuid() - val paragraphs = listOf( - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ), - Block( - id = MockDataFactory.randomString(), - content = Block.Content.Text( - marks = emptyList(), - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.P - ), - children = emptyList(), - fields = Block.Fields.empty() - ) - ) + val paragraphs = listOf(StubParagraph(), StubParagraph(), StubParagraph()) val page = listOf( Block( @@ -4199,21 +4225,48 @@ open class EditorViewModelTest { BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[1].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) }, paragraphs[2].let { p -> BlockView.Text.Paragraph( id = p.id, marks = emptyList(), - text = p.content().text + text = p.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt index 6fe5044496..b5f00f1d30 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBackspaceDeleteTest.kt @@ -23,8 +23,10 @@ import com.anytypeio.anytype.domain.block.interactor.UnlinkBlocks import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.block.interactor.UpdateTextStyle import com.anytypeio.anytype.domain.event.interactor.InterceptEvents +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -151,7 +153,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { id = parent.id, isFocused = true, cursor = parent.content().text.length, - text = parent.content().text + text = parent.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -264,14 +275,35 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = parent.id, isFocused = false, - text = parent.content().text + text = parent.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Bulleted( id = child1.id, isFocused = true, indent = 1, cursor = child1.content().text.length, - text = child1.content().text + text = child1.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -384,14 +416,35 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = parent.id, isFocused = false, - text = parent.content().text + text = parent.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Bulleted( indent = 1, id = child1.id, isFocused = true, cursor = child1.content().text.length, - text = child1.content().text + text = child1.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -486,7 +539,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = paragraph.id, isFocused = true, - text = paragraph.content().text + text = paragraph.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), ) ) @@ -593,7 +655,16 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = paragraph.id, isFocused = true, - text = paragraph.content().text + text = paragraph.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt index 69a8311c2f..39e9ee512d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorDuplicateTest.kt @@ -3,12 +3,15 @@ package com.anytypeio.anytype.presentation.editor.editor import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Event +import com.anytypeio.anytype.core_models.StubTitle import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.block.interactor.DuplicateBlock +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockBlockFactory import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test @@ -28,16 +31,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { @get:Rule val coroutineTestRule = CoroutinesTestRule() - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + val title = StubTitle() val header = Block( id = MockDataFactory.randomUuid(), @@ -184,16 +178,43 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = a.id, text = a.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.DividerLine( id = b.id, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = c.id, text = c.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = c.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -222,20 +243,56 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = a.id, text = a.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.DividerLine( id = b.id, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.DividerLine( id = copy.id, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = copy.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = c.id, text = c.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = c.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -298,19 +355,49 @@ class EditorDuplicateTest : EditorPresentationTestSetup() { id = a.id, text = a.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = b.id, text = b.content().text, mode = BlockView.Mode.READ, isSelected = true, - indent = 1 + indent = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = c.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = c.id, text = c.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = c.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt index 8f86c23bf3..21e546ee04 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorFeaturedRelationsTest.kt @@ -7,6 +7,7 @@ import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView @@ -157,7 +158,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -248,7 +258,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -345,7 +364,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -453,7 +481,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -570,7 +607,16 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt index 49d29d2073..ab5cc8a276 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorGranularChangeTest.kt @@ -4,7 +4,9 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test @@ -108,7 +110,16 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() { ), BlockView.Text.Checkbox( id = checkbox.id, - text = checkbox.content().text + text = checkbox.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = checkbox.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -125,7 +136,16 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() { BlockView.Text.Checkbox( id = checkbox.id, text = checkbox.content().text, - isChecked = true + isChecked = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = checkbox.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt index e498a7cf93..73ec24cb16 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLatexBlockTest.kt @@ -3,8 +3,10 @@ package com.anytypeio.anytype.presentation.editor.editor import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockBlockFactory import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -153,7 +155,16 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() { id = p.id, isFocused = false, text = p.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = p.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Latex( id = latex.id, diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt index e669f85937..ff85a97e6a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorListBlockTest.kt @@ -4,11 +4,15 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Event import com.anytypeio.anytype.core_models.SmartBlockType +import com.anytypeio.anytype.core_models.StubTitle +import com.anytypeio.anytype.core_models.ThemeColor import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.block.interactor.SplitBlock import com.anytypeio.anytype.domain.block.interactor.UpdateTextStyle +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -30,16 +34,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() { @get:Rule val coroutineTestRule = CoroutinesTestRule() - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + val title = StubTitle() val header = Block( id = MockDataFactory.randomUuid(), @@ -332,26 +327,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() { // SETUP - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) - - val header = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Layout( - type = Block.Content.Layout.Type.HEADER - ), - fields = Block.Fields.empty(), - children = listOf(title.id) - ) - val style = Block.Content.Text.Style.CHECKBOX val child = MockDataFactory.randomUuid() @@ -417,7 +392,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { text = "", isFocused = false, isChecked = false, - indent = 0 + indent = 0, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -456,7 +440,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = child, text = "", - isFocused = true + isFocused = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -469,26 +462,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() { // SETUP - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) - - val header = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Layout( - type = Block.Content.Layout.Type.HEADER - ), - fields = Block.Fields.empty(), - children = listOf(title.id) - ) - val style = Block.Content.Text.Style.BULLET val child = MockDataFactory.randomUuid() @@ -553,7 +526,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { id = child, text = "", isFocused = false, - indent = 0 + indent = 0, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -592,7 +574,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = child, text = "", - isFocused = true + isFocused = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -690,7 +681,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { text = "", isFocused = false, indent = 0, - isEmpty = true + isEmpty = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -729,7 +729,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = child, text = "", - isFocused = true + isFocused = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -742,26 +751,6 @@ class EditorListBlockTest : EditorPresentationTestSetup() { // SETUP - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) - - val header = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Layout( - type = Block.Content.Layout.Type.HEADER - ), - fields = Block.Fields.empty(), - children = listOf(title.id) - ) - val style = Block.Content.Text.Style.NUMBERED val child = MockDataFactory.randomUuid() @@ -827,7 +816,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { text = "", isFocused = false, indent = 0, - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) @@ -866,7 +864,16 @@ class EditorListBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = child, text = "", - isFocused = true + isFocused = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt index 35efe2f0c1..287c32107a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorLockPageTest.kt @@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_models.SmartBlockType +import com.anytypeio.anytype.core_models.StubTitle import com.anytypeio.anytype.core_models.ThemeColor import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.core_utils.common.EventWrapper @@ -12,6 +13,7 @@ import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockBlockFactory import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.navigation.AppNavigation import com.anytypeio.anytype.presentation.objects.ObjectIcon import com.anytypeio.anytype.presentation.util.CoroutinesTestRule @@ -32,16 +34,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() { @get:Rule val coroutineTestRule = CoroutinesTestRule() - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + val title = StubTitle() val header = Block( id = MockDataFactory.randomUuid(), @@ -105,7 +98,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() { BlockView.Text.Bulleted( id = child.id, text = child.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = child.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -165,7 +167,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() { BlockView.Text.Bulleted( id = child.id, text = child.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = child.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -225,7 +236,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() { BlockView.Text.Bulleted( id = child.id, text = child.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = child.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -289,6 +309,15 @@ class EditorLockPageTest : EditorPresentationTestSetup() { BlockView.LinkToObject.Default.Text( id = link.id, icon = ObjectIcon.Basic.Avatar(""), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = link.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -393,7 +422,16 @@ class EditorLockPageTest : EditorPresentationTestSetup() { param = target ) ), - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = paragraph.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -484,7 +522,17 @@ class EditorLockPageTest : EditorPresentationTestSetup() { description = bookmarkDescription, title = bookmarkTitle, mode = BlockView.Mode.READ, - isPreviousBlockMedia = false + isPreviousBlockMedia = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = bookmark.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Card + ) + ) + } else { + emptyList() + } ) ) @@ -572,7 +620,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() { listOf( BlockView.Decoration( background = ThemeColor.DEFAULT, - style = BlockView.Decoration.Style.None + style = BlockView.Decoration.Style.Card ) ) } else { @@ -666,7 +714,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() { listOf( BlockView.Decoration( background = ThemeColor.DEFAULT, - style = BlockView.Decoration.Style.None + style = BlockView.Decoration.Style.Card ) ) } else { diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt index 8c9192e5a0..5c1c36f9e9 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMarkupObjectTest.kt @@ -6,9 +6,11 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.ObjectType.Companion.PAGE_URL import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -122,7 +124,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() { ), indent = 0, text = "Start Foobar End", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -279,7 +290,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() { ), indent = 0, text = "Start Link Object Mention End", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -444,7 +464,16 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() { ), indent = 0, text = "Start Link Object Mention End", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt index f26401a1c0..1d30bfdd12 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMentionTest.kt @@ -12,11 +12,13 @@ import com.anytypeio.anytype.domain.base.Result import com.anytypeio.anytype.domain.event.interactor.InterceptEvents import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider import com.anytypeio.anytype.domain.page.CreateNewDocument +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState import com.anytypeio.anytype.presentation.editor.editor.mention.MentionConst.MENTION_TITLE_EMPTY import com.anytypeio.anytype.presentation.editor.editor.mention.MentionEvent import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -221,7 +223,16 @@ class EditorMentionTest : EditorPresentationTestSetup() { ), indent = 0, text = "page about Avant-Garde Jazz music", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -381,7 +392,16 @@ class EditorMentionTest : EditorPresentationTestSetup() { ), indent = 0, text = "page about Jazz music", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -541,7 +561,16 @@ class EditorMentionTest : EditorPresentationTestSetup() { ), indent = 0, text = "page about Untitled music", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -900,7 +929,16 @@ class EditorMentionTest : EditorPresentationTestSetup() { ), indent = 0, text = "Start Foob end", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -1037,7 +1075,16 @@ class EditorMentionTest : EditorPresentationTestSetup() { ), indent = 0, text = "Start Untitled end", - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt index 6e18152a6f..7afc444b6c 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorMultiSelectModeTest.kt @@ -3,10 +3,12 @@ package com.anytypeio.anytype.presentation.editor.editor import android.os.Build import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block +import com.anytypeio.anytype.core_models.StubTitle import com.anytypeio.anytype.core_models.ThemeColor import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.block.interactor.UnlinkBlocks import com.anytypeio.anytype.domain.clipboard.Copy +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockBlockContentFactory.StubLinkContent import com.anytypeio.anytype.presentation.MockBlockFactory import com.anytypeio.anytype.presentation.MockBlockFactory.link @@ -18,6 +20,7 @@ import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelStat import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.editor.styling.StyleToolbarState +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -43,16 +46,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { @get:Rule val coroutineTestRule = CoroutinesTestRule() - val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - text = MockDataFactory.randomString(), - style = Block.Content.Text.Style.TITLE, - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + val title = StubTitle() val header = Block( id = MockDataFactory.randomUuid(), @@ -197,7 +191,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 0, text = parent.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val child1View = BlockView.Text.Paragraph( @@ -207,7 +210,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 1, text = child1.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val child2View = BlockView.Text.Paragraph( @@ -217,7 +232,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 1, text = child2.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val grandchild1View = BlockView.Text.Paragraph( @@ -227,7 +254,22 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 2, text = grandchild1.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = grandchild1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val grandchild2View = BlockView.Text.Paragraph( @@ -237,7 +279,22 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 2, text = grandchild2.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = grandchild2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) vm.state.test().apply { @@ -407,7 +464,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 0, text = parent.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val child1View = BlockView.Text.Paragraph( @@ -417,7 +483,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 1, text = child1.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) val child2View = BlockView.Text.Paragraph( @@ -427,7 +505,19 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { marks = emptyList(), indent = 1, text = child2.content().text, - mode = BlockView.Mode.READ + mode = BlockView.Mode.READ, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = parent.parseThemeBackgroundColor() + ), + BlockView.Decoration( + background = child2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) vm.state.test().apply { @@ -702,7 +792,16 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { id = a.id, text = a.content().text, mode = BlockView.Mode.EDIT, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -867,19 +966,46 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() { id = a.id, text = a.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = b.id, text = b.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = c.id, text = c.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = c.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt index e7854445e8..bf395d7419 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorQuickStartingScrollAndMoveTest.kt @@ -3,10 +3,12 @@ package com.anytypeio.anytype.presentation.editor.editor import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState.Toolbar import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -141,13 +143,31 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { text = a.content().text, number = 1, mode = BlockView.Mode.READ, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = b.id, text = b.content().text, mode = BlockView.Mode.READ, - isSelected = true + isSelected = true, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -239,13 +259,31 @@ class EditorQuickStartingScrollAndMoveTest : EditorPresentationTestSetup() { text = a.content().text, number = 1, mode = BlockView.Mode.EDIT, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = b.id, text = b.content().text, mode = BlockView.Mode.EDIT, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt index 6615b12445..9d3cc47453 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorRelationBlockTest.kt @@ -5,7 +5,9 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_models.SmartBlockType +import com.anytypeio.anytype.core_models.StubTitle import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor @@ -28,16 +30,7 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { @get:Rule val coroutineTestRule = CoroutinesTestRule() - private val title = Block( - id = MockDataFactory.randomUuid(), - content = Block.Content.Text( - style = Block.Content.Text.Style.TITLE, - text = MockDataFactory.randomString(), - marks = emptyList() - ), - children = emptyList(), - fields = Block.Fields.empty() - ) + private val title = StubTitle() private val header = Block( id = MockDataFactory.randomUuid(), @@ -122,7 +115,16 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = a.id, text = a.content().text, - mode = BlockView.Mode.EDIT + mode = BlockView.Mode.EDIT, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Relation.Related( id = b.id, @@ -132,7 +134,15 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { value = value, format = relation.format ), - decorations = listOf() + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = b.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -228,13 +238,30 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Relation.Placeholder( id = relationBlock.id, indent = 0, isSelected = false, - decorations = listOf() + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = relationBlock.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -332,7 +359,16 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Relation.Related( id = relationBlock.id, @@ -345,7 +381,15 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { isFeatured = false, format = r2.format ), - decorations = listOf() + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = relationBlock.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) @@ -444,13 +488,30 @@ class EditorRelationBlockTest : EditorPresentationTestSetup() { background = block.parseThemeBackgroundColor(), text = block.content().text, alignment = block.content().align?.toView(), - number = 1 + number = 1, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Relation.Placeholder( id = relationBlock.id, indent = 0, isSelected = false, - decorations = listOf() + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = relationBlock.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt index 765cf8db4d..26ad3e5eeb 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorScrollAndMoveTest.kt @@ -5,12 +5,14 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Position import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.block.interactor.Move +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockBlockFactory.link import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.presentation.util.TXT import com.anytypeio.anytype.test_utils.MockDataFactory @@ -281,7 +283,16 @@ class EditorScrollAndMoveTest : EditorPresentationTestSetup() { id = a.id, text = a.content().text, mode = BlockView.Mode.EDIT, - isSelected = false + isSelected = false, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = a.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt index 62179217e0..03b9c3940c 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTableOfContentsBlockTest.kt @@ -5,6 +5,7 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.SmartBlockType import com.anytypeio.anytype.core_models.ext.content +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView @@ -275,57 +276,161 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = blockText1.id, indent = 0, - text = blockText1.content.asText().text + text = blockText1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.One( id = blockHeaderOne1.id, indent = 0, - text = blockHeaderOne1.content.asText().text + text = blockHeaderOne1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText2.id, indent = 0, - text = blockText2.content.asText().text + text = blockText2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo1.id, indent = 0, - text = blockHeaderTwo1.content.asText().text + text = blockHeaderTwo1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText3.id, indent = 0, - text = blockText3.content.asText().text + text = blockText3.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText3.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.One( id = blockHeaderOne2.id, indent = 0, - text = blockHeaderOne2.content.asText().text + text = blockHeaderOne2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText4.id, indent = 0, - text = blockText4.content.asText().text + text = blockText4.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText4.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo2.id, indent = 0, - text = blockHeaderTwo2.content.asText().text + text = blockHeaderTwo2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText5.id, indent = 0, - text = blockText5.content.asText().text + text = blockText5.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText5.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree.id, indent = 0, - text = blockHeaderThree.content.asText().text + text = blockHeaderThree.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText6.id, indent = 0, - text = blockText6.content.asText().text + text = blockText6.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText6.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -489,32 +594,89 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = blockText1.id, indent = 0, - text = blockText1.content.asText().text + text = blockText1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.One( id = blockHeaderOne.id, indent = 0, - text = blockHeaderOne.content.asText().text + text = blockHeaderOne.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText2.id, indent = 0, - text = blockText2.content.asText().text + text = blockText2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo.id, indent = 0, - text = blockHeaderTwo.content.asText().text + text = blockHeaderTwo.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText3.id, indent = 0, - text = blockText3.content.asText().text + text = blockText3.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText3.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree.id, indent = 0, - text = blockHeaderThree.content.asText().text + text = blockHeaderThree.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ) ) ) @@ -566,17 +728,45 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = blockText1.id, indent = 0, - text = blockText1.content.asText().text + text = blockText1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText1.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.One( id = blockHeaderOne.id, indent = 0, - text = blockHeaderOne.content.asText().text + text = blockHeaderOne.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Paragraph( id = blockText2.id, indent = 0, - text = blockText2.content.asText().text + text = blockText2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText2.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo.id, @@ -586,12 +776,31 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Paragraph( id = blockText3.id, indent = 0, - text = blockText3.content.asText().text + text = blockText3.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockText3.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree.id, indent = 0, - text = blockHeaderThree.content.asText().text + text = blockHeaderThree.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ) ) ) @@ -750,27 +959,77 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Header.One( id = blockHeaderOne1.id, indent = 0, - text = blockHeaderOne1.content.asText().text + text = blockHeaderOne1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo1.id, indent = 0, - text = blockHeaderTwo1.content.asText().text + text = blockHeaderTwo1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree.id, indent = 0, - text = blockHeaderThree.content.asText().text + text = blockHeaderThree.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo2.id, indent = 0, - text = blockHeaderTwo2.content.asText().text + text = blockHeaderTwo2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree2.id, indent = 0, - text = blockHeaderThree2.content.asText().text + text = blockHeaderThree2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ) ) ) @@ -946,27 +1205,77 @@ class EditorTableOfContentsBlockTest : EditorPresentationTestSetup() { BlockView.Text.Header.One( id = blockHeaderOne1.id, indent = 0, - text = blockHeaderOne1.content.asText().text + text = blockHeaderOne1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderOne1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H1 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo1.id, indent = 0, - text = blockHeaderTwo1.content.asText().text + text = blockHeaderTwo1.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo1.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree.id, indent = 0, - text = blockHeaderThree.content.asText().text + text = blockHeaderThree.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Two( id = blockHeaderTwo2.id, indent = 0, - text = blockHeaderTwo2.content.asText().text + text = blockHeaderTwo2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderTwo2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H2 + ) + ) + } else { + emptyList() + } ), BlockView.Text.Header.Three( id = blockHeaderThree2.id, indent = 0, - text = blockHeaderThree2.content.asText().text + text = blockHeaderThree2.content.asText().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = blockHeaderThree2.parseThemeBackgroundColor(), + style = BlockView.Decoration.Style.Header.H3 + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt index 2f1a2e635d..026e97c8b8 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorTitleTest.kt @@ -9,8 +9,10 @@ import com.anytypeio.anytype.core_models.ext.content import com.anytypeio.anytype.domain.block.interactor.SplitBlock import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.event.interactor.InterceptEvents +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.EditorViewModel import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.util.CoroutinesTestRule import com.anytypeio.anytype.test_utils.MockDataFactory import com.jraska.livedata.test @@ -326,7 +328,16 @@ class EditorTitleTest : EditorPresentationTestSetup() { ), BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -347,7 +358,16 @@ class EditorTitleTest : EditorPresentationTestSetup() { ), BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) @@ -440,7 +460,16 @@ class EditorTitleTest : EditorPresentationTestSetup() { ), BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) ) ) diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/TableBlockRendererTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/TableBlockRendererTest.kt index 5ee5e6a7d9..63789c441a 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/TableBlockRendererTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/table/TableBlockRendererTest.kt @@ -21,9 +21,11 @@ import com.anytypeio.anytype.domain.editor.Editor import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider import com.anytypeio.anytype.core_models.ThemeColor +import com.anytypeio.anytype.presentation.BuildConfig import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer import com.anytypeio.anytype.presentation.editor.render.DefaultBlockViewRenderer +import com.anytypeio.anytype.presentation.editor.render.parseThemeBackgroundColor import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder import com.anytypeio.anytype.presentation.util.TXT import kotlinx.coroutines.runBlocking @@ -34,6 +36,7 @@ import org.junit.Test import org.mockito.Mock import org.mockito.MockitoAnnotations import kotlin.test.assertEquals +import kotlin.test.asserter class TableBlockRendererTest { @@ -222,7 +225,16 @@ class TableBlockRendererTest { ) + blocksUpper.map { block: Block -> BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } + listOf( BlockView.Table( @@ -236,7 +248,16 @@ class TableBlockRendererTest { BlockView.Text.Numbered( id = block.id, text = block.content().text, - number = idx.inc() + number = idx.inc(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = block.parseThemeBackgroundColor() + ) + ) + } else { + emptyList() + } ) } @@ -354,7 +375,16 @@ class TableBlockRendererTest { ) + blocksUpper.map { block: Block -> BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) } + listOf( BlockView.Table( @@ -368,7 +398,16 @@ class TableBlockRendererTest { BlockView.Text.Numbered( id = block.id, text = block.content().text, - number = idx.inc() + number = idx.inc(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) } @@ -564,7 +603,16 @@ class TableBlockRendererTest { ) + blocksUpper.map { block: Block -> BlockView.Text.Bulleted( id = block.id, - text = block.content().text + text = block.content().text, + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) } + listOf( BlockView.Table( @@ -578,7 +626,16 @@ class TableBlockRendererTest { BlockView.Text.Numbered( id = block.id, text = block.content().text, - number = idx.inc() + number = idx.inc(), + decorations = if (BuildConfig.NESTED_DECORATION_ENABLED) { + listOf( + BlockView.Decoration( + background = ThemeColor.DEFAULT + ) + ) + } else { + emptyList() + } ) } diff --git a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Block.kt b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Block.kt index 9d714343b9..54d58ffb2c 100644 --- a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Block.kt +++ b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Block.kt @@ -72,13 +72,15 @@ fun StubParagraph( text: String = MockDataFactory.randomString(), children: List = emptyList(), marks: List = emptyList(), - backgroundColor: String? = null + backgroundColor: String? = null, + textColor: String? = null ): Block = Block( id = id, content = StubTextContent( text = text, style = Block.Content.Text.Style.P, - marks = marks + marks = marks, + color = textColor ), children = children, fields = Block.Fields.empty(), @@ -93,7 +95,7 @@ fun StubFile( name: String = MockDataFactory.randomString(), size: Long = MockDataFactory.randomLong(), type: Block.Content.File.Type? = null, - state: Block.Content.File.State? = null + state: Block.Content.File.State? = null, ) : Block = Block( id = id, children = children,