Context-detection API for Android developed as a university project
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

JourneyUtilGetStepsTest.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2009-2010 Chris Smith
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package uk.co.md87.android.contextanalyser;
  23. import java.util.List;
  24. import java.util.Arrays;
  25. import java.util.Collection;
  26. import org.junit.runners.Parameterized.Parameters;
  27. import org.junit.Test;
  28. import org.junit.runner.RunWith;
  29. import org.junit.runners.Parameterized;
  30. import uk.co.md87.android.common.model.JourneyStep;
  31. import static org.junit.Assert.*;
  32. /**
  33. * Unit tests for JourneyUtil.getSteps.
  34. *
  35. * @author chris
  36. */
  37. @RunWith(Parameterized.class)
  38. public class JourneyUtilGetStepsTest {
  39. private final String[] activities;
  40. private final JourneyStep[] expected;
  41. public JourneyUtilGetStepsTest(final String[] activities, final JourneyStep[] expected) {
  42. this.activities = activities;
  43. this.expected = expected;
  44. }
  45. @Test
  46. public void testGetSteps() {
  47. final List<JourneyStep> result = JourneyUtil.getSteps(Arrays.asList(activities));
  48. assertEquals(Arrays.asList(expected), result);
  49. }
  50. @Parameters
  51. public static Collection<Object[]> data() {
  52. return Arrays.asList(new Object[][] {
  53. {new String[]{}, new JourneyStep[]{}},
  54. {new String[]{"A"}, new JourneyStep[]{new JourneyStep("A", 1)}},
  55. {new String[]{"A", "B"}, new JourneyStep[]{new JourneyStep("A", 1),
  56. new JourneyStep("B", 1)}},
  57. {new String[]{"A", "A", "A", "B"}, new JourneyStep[]{new JourneyStep("A", 3),
  58. new JourneyStep("B", 1)}},
  59. {new String[]{"A", "B", "A", "B"}, new JourneyStep[]{new JourneyStep("A", 1),
  60. new JourneyStep("B", 1), new JourneyStep("A", 1), new JourneyStep("B", 1)}},
  61. {new String[]{"A", "A", "A", "A", "A"}, new JourneyStep[]{new JourneyStep("A", 5)}},
  62. });
  63. }
  64. }