Android Open Source - CalWatch Event Layout Uniform Test






From Project

Back to project page CalWatch.

License

The source code is released under:

GNU General Public License

If you think the Android project CalWatch listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dwallach.calwatch;
/*from  w w  w.  j  a v  a2  s.  c om*/
import android.util.Log;

import junit.framework.TestCase;

import org.dwallach.calwatch.WireEvent;

import java.util.LinkedList;
import java.util.List;

public class EventLayoutUniformTest extends TestCase {
    private final static String TAG = "EventLayoutUniformTest";

    public void testGo() throws Exception {
        List<EventWrapper> data = new Builder().add(new WireEvent(1L, 10L, 1))
                .add(new WireEvent(11L, 20L, 2))
                .add(new WireEvent(21L, 30L, 3))
                .add(new WireEvent(31L, 40L, 4))
                .get();

        boolean success = EventLayoutUniform.go(data);
        assertEquals(success, true);
        levelCheck(data, EventLayoutUniform.MAXLEVEL);

        data = new Builder().add(new WireEvent(1L, 10L, 1))
                .add(new WireEvent(5L, 20L, 2))
                .add(new WireEvent(21L, 30L, 3))
                .add(new WireEvent(31L, 40L, 4))
                .get();

        success = EventLayoutUniform.go(data);
        assertEquals(success, true);
        levelCheck(data, EventLayoutUniform.MAXLEVEL);

        // okay, now for something really evil: a really long event with three stacks below it of
        // difference sizes, and another stack on the side

        data = new Builder().add(new WireEvent(1L, 30L, 1))
                .add(new WireEvent(1L, 5L, 2))
                .add(new WireEvent(11L, 15L, 3))
                .add(new WireEvent(11L, 15L, 4))
                .add(new WireEvent(21L, 25L, 5))
                .add(new WireEvent(21L, 25L, 6))
                .add(new WireEvent(21L, 25L, 7))
                .add(new WireEvent(31L, 35L, 8))
                .add(new WireEvent(31L, 35L, 9))
                .get();

        success = EventLayoutUniform.go(data);
        assertEquals(success, true);
        levelCheck(data, EventLayoutUniform.MAXLEVEL);
    }

    class Builder {
        List<EventWrapper> output;

        public Builder() {
            output = new LinkedList<EventWrapper>();
        }

        public Builder add(EventWrapper e) {
            output.add(e);
            return this;
        }

        public Builder add(WireEvent e) {
            return add(new EventWrapper(e));
        }

        public List<EventWrapper> get() {
            return output;
        }
    }

    private void levelCheck(List<EventWrapper> events, int maxLevel) {
        int nEvents = events.size();

        for (int i = 0; i < nEvents; i++) {
            EventWrapper e = events.get(i);
            assertTrue("event: " + e.toString(), e.getMinLevel() >= 0);
            assertTrue("event: " + e.toString(), e.getMaxLevel() <= maxLevel);
            Log.v(TAG, "event " + i + ": minLevel(" + e.getMinLevel() + "), maxLevel(" + e.getMaxLevel() + ")");
        }

    }
}




Java Source Code List

EDU.Washington.grad.gjb.cassowary.CL.java
EDU.Washington.grad.gjb.cassowary.ClAbstractVariable.java
EDU.Washington.grad.gjb.cassowary.ClConstraint.java
EDU.Washington.grad.gjb.cassowary.ClDouble.java
EDU.Washington.grad.gjb.cassowary.ClDummyVariable.java
EDU.Washington.grad.gjb.cassowary.ClEditConstraint.java
EDU.Washington.grad.gjb.cassowary.ClEditInfo.java
EDU.Washington.grad.gjb.cassowary.ClEditOrStayConstraint.java
EDU.Washington.grad.gjb.cassowary.ClLinearConstraint.java
EDU.Washington.grad.gjb.cassowary.ClLinearEquation.java
EDU.Washington.grad.gjb.cassowary.ClLinearExpression.java
EDU.Washington.grad.gjb.cassowary.ClLinearInequality.java
EDU.Washington.grad.gjb.cassowary.ClObjectiveVariable.java
EDU.Washington.grad.gjb.cassowary.ClPoint.java
EDU.Washington.grad.gjb.cassowary.ClSimplexSolver.java
EDU.Washington.grad.gjb.cassowary.ClSlackVariable.java
EDU.Washington.grad.gjb.cassowary.ClStayConstraint.java
EDU.Washington.grad.gjb.cassowary.ClStrength.java
EDU.Washington.grad.gjb.cassowary.ClSymbolicWeight.java
EDU.Washington.grad.gjb.cassowary.ClTableau.java
EDU.Washington.grad.gjb.cassowary.ClTestColumns.java
EDU.Washington.grad.gjb.cassowary.ClTests.java
EDU.Washington.grad.gjb.cassowary.ClVariable.java
EDU.Washington.grad.gjb.cassowary.ExCLConstraintNotFound.java
EDU.Washington.grad.gjb.cassowary.ExCLError.java
EDU.Washington.grad.gjb.cassowary.ExCLInternalError.java
EDU.Washington.grad.gjb.cassowary.ExCLNonlinearExpression.java
EDU.Washington.grad.gjb.cassowary.ExCLNotEnoughStays.java
EDU.Washington.grad.gjb.cassowary.ExCLRequiredFailure.java
EDU.Washington.grad.gjb.cassowary.ExCLTooDifficult.java
EDU.Washington.grad.gjb.cassowary.Set.java
EDU.Washington.grad.gjb.cassowary.Timer.java
EDU.Washington.grad.gjb.cassowary.sym.java
EDU.Washington.grad.gjb.cassowary.testClLinearExpression.java
EDU.Washington.grad.gjb.cassowary.testClStrength.java
org.dwallach.calwatch.ApplicationTest.java
org.dwallach.calwatch.BatteryWrapper.java
org.dwallach.calwatch.CalWatchFaceService.java
org.dwallach.calwatch.CalendarFetcher.java
org.dwallach.calwatch.ClockFace.java
org.dwallach.calwatch.ClockState.java
org.dwallach.calwatch.Constants.java
org.dwallach.calwatch.EventLayoutTest.java
org.dwallach.calwatch.EventLayoutUniformTest.java
org.dwallach.calwatch.EventLayoutUniform.java
org.dwallach.calwatch.EventLayout.java
org.dwallach.calwatch.EventWrapper.java
org.dwallach.calwatch.MyViewAnim.java
org.dwallach.calwatch.PaintCan.java
org.dwallach.calwatch.PathCache.java
org.dwallach.calwatch.PhoneActivity.java
org.dwallach.calwatch.PreferencesHelper.java
org.dwallach.calwatch.TimeWrapper.java
org.dwallach.calwatch.VersionWrapper.java
org.dwallach.calwatch.WatchCalendarService.java
org.dwallach.calwatch.WearReceiverService.java
org.dwallach.calwatch.WearSender.java
org.dwallach.calwatch.WireEvent.java
org.dwallach.calwatch.WireUpdate.java
org.dwallach.calwatch.XWatchfaceReceiver.java