Lines Matching defs:Utility
17 package com.android.emailcommon.utility;
28 import com.android.emailcommon.utility.Utility.NewFileCreator;
55 * This is a series of unit tests for the Utility class. These tests must be locally
69 assertNull(Utility.toUtf8(null));
70 MoreAsserts.assertEquals(new byte[] {}, Utility.toUtf8(""));
71 MoreAsserts.assertEquals(b('a'), Utility.toUtf8("a"));
72 MoreAsserts.assertEquals(b('A', 'B', 'C'), Utility.toUtf8("ABC"));
74 Utility.toUtf8("\u65E5\u672C\u8A9E"));
78 assertNull(Utility.fromUtf8(null));
79 assertEquals("", Utility.fromUtf8(new byte[] {}));
80 assertEquals("a", Utility.fromUtf8(b('a')));
81 assertEquals("ABC", Utility.fromUtf8(b('A', 'B', 'C')));
83 Utility.fromUtf8(b(0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E)));
97 byte[] bytes = Utility.toUtf8(aChar);
98 assertTrue("0", Utility.isFirstUtf8Byte(bytes[0]));
100 assertFalse(Integer.toString(i), Utility.isFirstUtf8Byte(bytes[i]));
106 String hex = Utility.byteToHex((byte) i);
113 assertEquals("", Utility.replaceBareLfWithCrlf(""));
114 assertEquals("", Utility.replaceBareLfWithCrlf("\r"));
115 assertEquals("\r\n", Utility.replaceBareLfWithCrlf("\r\n"));
116 assertEquals("\r\n", Utility.replaceBareLfWithCrlf("\n"));
117 assertEquals("\r\n\r\n\r\n", Utility.replaceBareLfWithCrlf("\n\n\n"));
118 assertEquals("A\r\nB\r\nC\r\nD", Utility.replaceBareLfWithCrlf("A\nB\r\nC\nD"));
122 assertEquals("1438642069", Utility.getSmallHash(""));
123 assertEquals("1354919068", Utility.getSmallHash("abc"));
130 assertEquals(0, Utility.getSmallHashFromSha1(sha1));
135 assertEquals(Integer.MAX_VALUE, Utility.getSmallHashFromSha1(sha1));
140 Utility.getSmallHashFromSha1(sha1);
145 assertNull(Utility.cleanUpMimeDate(null));
146 assertEquals("", Utility.cleanUpMimeDate(""));
147 assertEquals("abc", Utility.cleanUpMimeDate("abc"));
148 assertEquals("GMT", Utility.cleanUpMimeDate("GMT"));
149 assertEquals("0000", Utility.cleanUpMimeDate("0000"));
150 assertEquals("-0000", Utility.cleanUpMimeDate("-0000"));
151 assertEquals("+1234", Utility.cleanUpMimeDate("GMT+1234"));
152 assertEquals("-1234", Utility.cleanUpMimeDate("GMT-1234"));
153 assertEquals("gmt-1234", Utility.cleanUpMimeDate("gmt-1234"));
154 assertEquals("GMT-123", Utility.cleanUpMimeDate("GMT-123"));
157 Utility.cleanUpMimeDate("Thu, 10 Dec 09 15:08:08 GMT-0700"));
159 Utility.cleanUpMimeDate("Thu, 10 Dec 09 15:08:08 -0700"));
205 Utility.createUniqueFileInternal(nfc, new File(dir), fileName).toString());
218 file = Utility.createUniqueFile(Environment.getExternalStorageDirectory(),
240 assertFalse(Utility.isPortFieldValid(view));
242 assertFalse(Utility.isPortFieldValid(view));
244 assertFalse(Utility.isPortFieldValid(view));
246 assertFalse(Utility.isPortFieldValid(view));
248 assertFalse(Utility.isPortFieldValid(view));
250 assertFalse(Utility.isPortFieldValid(view));
252 assertFalse(Utility.isPortFieldValid(view));
255 assertTrue(Utility.isPortFieldValid(view));
257 assertTrue(Utility.isPortFieldValid(view));
261 assertEquals(0, Utility.toPrimitiveLongArray(createLongCollection()).length);
263 final long[] one = Utility.toPrimitiveLongArray(createLongCollection(1));
267 final long[] two = Utility.toPrimitiveLongArray(createLongCollection(3, 4));
274 assertEquals(0, Utility.toLongSet(new long[] {}).size());
276 final Set<Long> one = Utility.toLongSet(new long[] {1});
280 final Set<Long> two = Utility.toLongSet(new long[] {1, 2});
303 assertEquals("name", Utility.getContentFileName(providerContext, uri));
308 assertEquals(lastPathSegment, Utility.getContentFileName(providerContext, notExistUri));
312 return Utility.getFirstRowLong(mockContext, Mailbox.CONTENT_URI,
384 Utility.updateLastSeenMessageKey(mockContext, account1.mId).get();
396 Utility.updateLastSeenMessageKey(mockContext, account2.mId).get();
408 Utility.updateLastSeenMessageKey(mockContext, account3.mId).get();
420 Utility.updateLastSeenMessageKey(mockContext, 0x1000000000000000L).get();
450 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c1)));
451 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c2)));
452 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c3)));
453 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(null)));
457 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c1)));
458 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c2)));
459 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(c3)));
460 assertFalse(TextUtils.isEmpty(Utility.dumpCursor(null)));
465 final Utility.CloseTraceCursorWrapper c =
466 Utility.CloseTraceCursorWrapper.alwaysCreateForTest(org);
469 assertNull(Utility.CloseTraceCursorWrapper.getTraceIfAvailable(c));
470 Utility.CloseTraceCursorWrapper.log(c); // shouldn't crash
474 assertNotNull(Utility.CloseTraceCursorWrapper.getTraceIfAvailable(c));
475 Utility.CloseTraceCursorWrapper.log(c);
478 Utility.CloseTraceCursorWrapper.log(null);
485 assertEquals(ssb, Utility.appendBold(ssb, "BO"));
497 assertTrue(Utility.areStringsEqual(s1, s2));
500 assertTrue(Utility.areStringsEqual(s1, s2));
503 assertFalse(Utility.areStringsEqual(s1, s2));
506 assertFalse(Utility.areStringsEqual(s1, s2));
510 assertFalse(Utility.areStringsEqual(s1, s2));
514 assertTrue(Utility.areStringsEqual(s1, s2));
518 assertTrue(Utility.isServerNameValid("a"));
519 assertTrue(Utility.isServerNameValid("gmail"));
520 assertTrue(Utility.isServerNameValid("gmail.com"));
521 assertTrue(Utility.isServerNameValid("gmail.com.x.y.z"));
522 assertTrue(Utility.isServerNameValid(" gmail.com.x.y.z "));
524 assertFalse(Utility.isServerNameValid(""));
525 assertFalse(Utility.isServerNameValid("$"));
526 assertFalse(Utility.isServerNameValid(" "));
538 assertEquals("", Utility.buildInSelection("c", null));
539 assertEquals("", Utility.buildInSelection("c", toColleciton()));
540 assertEquals("c in (1)", Utility.buildInSelection("c", toColleciton(1)));
541 assertEquals("c in (1,2)", Utility.buildInSelection("c", toColleciton(1, 2)));
542 assertEquals("c in (1,2,-500)", Utility.buildInSelection("c", toColleciton(1, 2, -500)));