Browse Source
* commit 'be61530ffbe25dbb3e68f90b75c6ffa9558c19ca': REPORT-39757 处理搜索词高亮 REPORT-39894 不将自适应布局和绝对布局的子类加入顶层 REPORT-39757 少个空格 REPORT-39757 AlphaFine无法搜索含空格的模板名称feature/big-screen
Hades
4 years ago
17 changed files with 235 additions and 128 deletions
@ -0,0 +1,79 @@
|
||||
package com.fr.design.mainframe.alphafine.search.manager.impl; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; |
||||
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
||||
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; |
||||
import com.fr.design.mainframe.alphafine.model.SearchResult; |
||||
import com.fr.file.filetree.FileNode; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.stable.project.ProjectConstants; |
||||
import com.fr.web.core.SessionPoolManager; |
||||
import com.fr.web.utils.WebUtils; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author Yyming |
||||
* @version 10.0 |
||||
* Created by Yyming on 2020/9/15 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({AlphaFineHelper.class,DesignerEnvManager.class}) |
||||
@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") |
||||
public class FileSearchManagerTest { |
||||
|
||||
@Test |
||||
public void doSearch() { |
||||
String searchText = "workb"; |
||||
FileSearchManager instance = FileSearchManager.getInstance(); |
||||
FileNode fileNode1 = EasyMock.createMock(FileNode.class); |
||||
FileNode fileNode2 = EasyMock.createMock(FileNode.class); |
||||
EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes(); |
||||
EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes(); |
||||
EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes(); |
||||
EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes(); |
||||
EasyMock.replay(fileNode1,fileNode2); |
||||
FileNode[] fileNodes = { fileNode1, fileNode2 }; |
||||
Reflect.on(instance).set("fileNodes",fileNodes); |
||||
|
||||
AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); |
||||
EasyMock.expect(configManager.isContainTemplate()).andReturn(true).anyTimes(); |
||||
EasyMock.replay(configManager); |
||||
|
||||
DesignerEnvManager manager = EasyMock.createMock(DesignerEnvManager.class); |
||||
EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(configManager).anyTimes(); |
||||
EasyMock.replay(manager); |
||||
PowerMock.mockStatic(DesignerEnvManager.class); |
||||
DesignerEnvManager.getEnvManager(); |
||||
PowerMock.expectLastCall().andReturn(manager).anyTimes(); |
||||
PowerMock.replay(DesignerEnvManager.class); |
||||
|
||||
List<AlphaCellModel> list = new ArrayList<>(); |
||||
PowerMock.mockStatic(AlphaFineHelper.class); |
||||
AlphaFineHelper.getFilterResult(); |
||||
PowerMock.expectLastCall().andReturn(list).anyTimes(); |
||||
AlphaFineHelper.findFolderName(""); |
||||
PowerMock.expectLastCall().andReturn("").anyTimes(); |
||||
AlphaFineHelper.checkCancel(); |
||||
PowerMock.expectLastCall().andVoid().anyTimes(); |
||||
PowerMock.replay(AlphaFineHelper.class); |
||||
|
||||
SearchResult alphaCellModels = new SearchResult(); |
||||
Reflect.on(instance).set("filterModelList",alphaCellModels); |
||||
Reflect.on(instance).call("doSearch",searchText); |
||||
assertEquals(alphaCellModels.size(),2); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.mainframe.alphafine.cell.render; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author Yyming |
||||
* @version 10.0 |
||||
* Created by Yyming on 2020/9/16 |
||||
*/ |
||||
public class ContentCellRenderTest { |
||||
|
||||
@Test |
||||
public void highLightModelName() { |
||||
String searchText = "workb"; |
||||
ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText}); |
||||
String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText}); |
||||
assertTrue(workbook.endsWith("workb</font>ook</body></HTML>")); |
||||
workbook = contentCellRender.highLightModelName("work book", new String[]{searchText}); |
||||
assertTrue(workbook.endsWith("work b</font>ook</body></HTML>")); |
||||
} |
||||
} |
Loading…
Reference in new issue