litesoft
@ 939
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
package org.litesoft.useragent; import org.junit.Test; import junit.framework.Assert; import java.io.*; import org.litesoft.core.typeutils.Objects; import java.util.*; public class UserAgentFormFactorDeterminerImplTest { public static final String USER_AGENT_FILES_SUB_DIR = "UserAgentFiles"; private static final UserAgentFormFactorDeterminer FFD = new UserAgentFormFactorDeterminerImpl(); private static String[] readTextFile( File pTextFile ) throws IOException { List<String> zLines = new ArrayList<>(); try (Scanner scanner = new Scanner( pTextFile, "UTF-8" )) { while ( scanner.hasNextLine() ) { zLines.add( scanner.nextLine() ); } } return zLines.toArray( new String[zLines.size()] ); } private static void checkFileEntries( UserAgentFormFactor pExpected, String pFileNameWithUserAgentPerLine ) throws IOException { String[] zLines = readTextFile( new File( USER_AGENT_FILES_SUB_DIR, pFileNameWithUserAgentPerLine + ".txt" ) ); for ( int i = 0; i < zLines.length; i++ ) { String zLine = zLines[i].trim(); if ( (zLine.length() != 0) && !zLine.startsWith( "!" ) ) { UserAgentFormFactor zActual = FFD.determine( zLine ); if ( zActual != pExpected ) { Assert.assertEquals( "From '" + pFileNameWithUserAgentPerLine + "[" + i + "]" + "': " + zLine, pExpected, zActual ); } } } } private static void checkEntriesFromFiles( UserAgentFormFactor pExpected, String... pFileNamesWithUserAgentPerLine ) throws IOException { for ( String zFileName : pFileNamesWithUserAgentPerLine ) { checkFileEntries( pExpected, zFileName ); } } @Test public void testDetermine() throws Exception { checkEntriesFromFiles( UserAgentFormFactor.SingleViewOnly, "iPhone", "iPod", "iPad", "Silk", "Tizen", "Kindle", "Fennec", "Android", "IE-Mobile", "SymbianOS", "OperaMini", "OperaMobi", "OperaTablet", "MobileFirefox" ); checkEntriesFromFiles( UserAgentFormFactor.MultiViewable, "Other" ); } } |
Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/useragent/UserAgentFormFactorDeterminerImplTest.java
Revision | Author | Commited | Message |
---|---|---|---|
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
926 Diff | GeorgeS | Fri 14 Mar, 2014 23:58:15 +0000 | Switched from Cookie to Param. |
924 Diff | GeorgeS | Fri 14 Mar, 2014 22:02:56 +0000 | Drop IWS |
920 | GeorgeS | Sun 16 Feb, 2014 19:06:51 +0000 | DDT w/ Jetty |