1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.webkit; 18 19 import android.test.AndroidTestCase; 20 import android.text.format.DateFormat; 21 import android.test.suitebuilder.annotation.MediumTest; 22 import android.util.Log; 23 import android.webkit.DateSorter; 24 25 import java.util.Calendar; 26 import java.util.Date; 27 28 public class WebkitTest extends AndroidTestCase { 29 30 private static final String LOGTAG = WebkitTest.class.getName(); 31 32 @MediumTest 33 public void testDateSorter() throws Exception { 34 /** 35 * Note: check the logging output manually to test 36 * nothing automated yet, besides object creation 37 */ 38 DateSorter dateSorter = new DateSorter(mContext); 39 Date date = new Date(); 40 41 for (int i = 0; i < DateSorter.DAY_COUNT; i++) { 42 Log.i(LOGTAG, "Boundary " + i + " " + dateSorter.getBoundary(i)); 43 Log.i(LOGTAG, "Label " + i + " " + dateSorter.getLabel(i)); 44 } 45 46 Calendar c = Calendar.getInstance(); 47 long time = c.getTimeInMillis(); 48 int index; 49 Log.i(LOGTAG, "now: " + dateSorter.getIndex(time)); 50 for (int i = 0; i < 20; i++) { 51 time -= 8 * 60 * 60 * 1000; // 8 hours 52 date.setTime(time); 53 c.setTime(date); 54 index = dateSorter.getIndex(time); 55 Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() + 56 " " + index + " " + dateSorter.getLabel(index)); 57 } 58 } 59 } 60