diff options
author | Eric Reed <ericreed@google.com> | 2022-03-04 21:29:34 -0800 |
---|---|---|
committer | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-03-17 00:09:53 +0000 |
commit | bfa3f658e6dbda6b05d61410e6365493e35fc9b5 (patch) | |
tree | 78bbce3e9aa7cea6f9a90ee5a0a6c98835a3f95b /android/testSrc | |
parent | c3b6b5677ab8eab68c3de0195f39d0fff3a811aa (diff) | |
download | idea-bfa3f658e6dbda6b05d61410e6365493e35fc9b5.tar.gz |
Add tests for ResourceUrlTreeNode
Test: N/A
Bug: 220017221
Change-Id: I41ce8b2881d273950647caa4a6cbde7665daa4a5
Diffstat (limited to 'android/testSrc')
-rw-r--r-- | android/testSrc/com/android/tools/idea/refactoring/modularize/ResourceUrlTreeNodeTest.kt | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/android/testSrc/com/android/tools/idea/refactoring/modularize/ResourceUrlTreeNodeTest.kt b/android/testSrc/com/android/tools/idea/refactoring/modularize/ResourceUrlTreeNodeTest.kt new file mode 100644 index 00000000000..ee740f85957 --- /dev/null +++ b/android/testSrc/com/android/tools/idea/refactoring/modularize/ResourceUrlTreeNodeTest.kt @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tools.idea.refactoring.modularize + +import com.android.resources.ResourceUrl +import com.android.testutils.MockitoKt.mock +import com.intellij.ui.ColoredTreeCellRenderer +import com.intellij.ui.SimpleTextAttributes +import icons.StudioIcons +import org.junit.Test +import org.mockito.Mockito +import org.mockito.Mockito.spy +import org.mockito.Mockito.verify +import org.mockito.Mockito.`when` as given + +class ResourceUrlTreeNodeTest { + + @Test + fun `render sets icon to Android file`() { + val renderer = mock<ColoredTreeCellRenderer>() + + ResourceUrlTreeNode(mock()).render(renderer) + + verify(renderer).icon = StudioIcons.Shell.Filetree.ANDROID_FILE + } + + @Test + fun `render appends the resource URL's string representation with the node's text attributes`() { + val renderer = mock<ColoredTreeCellRenderer>() + + val url = mock<ResourceUrl>() + val stringRep = "<a string representation of a ResourceUrl>" + given(url.toString()).thenReturn(stringRep) + + val node = spy(ResourceUrlTreeNode(url)) + val textAttr = mock<SimpleTextAttributes>() + Mockito.doReturn(textAttr).`when`(node).textAttributes + + node.render(renderer) + + verify(renderer).append(stringRep, textAttr) + } +}
\ No newline at end of file |