<commit_before>/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2016 GwtMaterialDesign
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package gwt.material.design.addins.client;

import com.google.gwt.user.client.ui.RootPanel;
import gwt.material.design.addins.client.base.GwtMaterialAddinsTest;
import gwt.material.design.addins.client.base.constants.AddinsCssName;
import gwt.material.design.addins.client.stepper.MaterialStep;
import gwt.material.design.addins.client.stepper.MaterialStepper;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.constants.CssName;
import gwt.material.design.client.ui.MaterialPanel;
import org.junit.Test;

/**
 * Test case for stepper component
 *
 * @author kevzlou7979
 */
public class MaterialStepperTest extends GwtMaterialAddinsTest {

    @Test
    public void testStepper() {
        MaterialStepper stepper = new MaterialStepper();
        checkWidget(stepper);
        checkStructure(stepper);
        checkStepNavigation(stepper);
    }

    private void checkStepNavigation(MaterialStepper stepper) {
        final boolean[] isStartFired = {false};
        stepper.addStartHandler(event -> {
             isStartFired[0] = true;
        });
        RootPanel.get().add(stepper);
        assertTrue(isStartFired[0]);
        assertEquals(stepper.getWidgetCount(), 5);
        assertEquals(stepper.getCurrentStep(), stepper.getWidget(0));
        // Next Step Test
        for (int i = 0; i < stepper.getWidgetCount() - 1; i++) {
            final boolean[] isNextFired = {false};
            stepper.addNextHandler(event -> {
                isNextFired[0] = true;
            });
            stepper.nextStep();
            assertTrue(stepper.getWidget(i) instanceof MaterialStep);
            MaterialStep step = (MaterialStep) stepper.getWidget(i + 1);
            assertEquals(stepper.getCurrentStep(), step);
            // Check Next Event
            assertTrue(isNextFired[0]);
        }

        // Previous Step Test
        final int lastStepIndex = stepper.getWidgetCount();
        stepper.goToStep(lastStepIndex); // Go to last step
        assertEquals(stepper.getCurrentStep(), stepper.getWidget(lastStepIndex - 1));
        for (int i = stepper.getWidgetCount() - 1; i > 0 ; i--) {
            final boolean[] isPreviousFired = {false};
            stepper.addPreviousHandler(event -> {
                isPreviousFired[0] = true;
            });

            stepper.prevStep();
            assertTrue(stepper.getWidget(i - 1) instanceof MaterialStep);
            MaterialStep step = (MaterialStep) stepper.getWidget(i - 1);
            assertEquals(stepper.getCurrentStep(), step);
            // Check Previous Event
            assertTrue(isPreviousFired[0]);
        }

        // Check Complete Event
        final boolean[] isCompleteFired = {false};
        stepper.addCompleteHandler(event -> {
            isCompleteFired[0] = true;
        });
        stepper.goToStep(lastStepIndex);
        stepper.nextStep();
        assertTrue(isCompleteFired[0]);

        // Reset the Stepper
        stepper.reset();
        assertEquals(stepper.getCurrentStepIndex(), 0);
        assertEquals(stepper.getWidget(0), stepper.getCurrentStep());
    }<commit_msg>Stepper - Horizontal and Vertical Axis Test<commit_after>/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2016 GwtMaterialDesign
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package gwt.material.design.addins.client;

import com.google.gwt.user.client.ui.RootPanel;
import gwt.material.design.addins.client.base.GwtMaterialAddinsTest;
import gwt.material.design.addins.client.base.constants.AddinsCssName;
import gwt.material.design.addins.client.stepper.MaterialStep;
import gwt.material.design.addins.client.stepper.MaterialStepper;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.constants.Axis;
import gwt.material.design.client.constants.CssName;
import gwt.material.design.client.ui.MaterialPanel;
import org.junit.Test;

/**
 * Test case for stepper component
 *
 * @author kevzlou7979
 */
public class MaterialStepperTest extends GwtMaterialAddinsTest {

    @Test
    public void testStepper() {
        MaterialStepper stepper = new MaterialStepper();
        checkWidget(stepper);
        checkStructure(stepper);
        checkStepNavigation(stepper);
        checkAxis(stepper);
    }

    protected <T extends MaterialStepper> void checkAxis(T stepper) {
        stepper.setAxis(Axis.VERTICAL);
        assertEquals(stepper.getAxis(), Axis.VERTICAL);
        assertTrue(stepper.getElement().hasClassName(Axis.VERTICAL.getCssName()));
        stepper.setAxis(Axis.HORIZONTAL);
        assertEquals(stepper.getAxis(), Axis.HORIZONTAL);
        assertTrue(stepper.getElement().hasClassName(Axis.HORIZONTAL.getCssName()));
    }

    protected <T extends MaterialStepper> void checkStepNavigation(T stepper) {
        final boolean[] isStartFired = {false};
        stepper.addStartHandler(event -> {
            isStartFired[0] = true;
        });
        RootPanel.get().add(stepper);
        assertTrue(isStartFired[0]);
        assertEquals(stepper.getWidgetCount(), 5);
        assertEquals(stepper.getCurrentStep(), stepper.getWidget(0));
        // Next Step Test
        for (int i = 0; i < stepper.getWidgetCount() - 1; i++) {
            final boolean[] isNextFired = {false};
            stepper.addNextHandler(event -> {
                isNextFired[0] = true;
            });
            stepper.nextStep();
            assertTrue(stepper.getWidget(i) instanceof MaterialStep);
            MaterialStep step = (MaterialStep) stepper.getWidget(i + 1);
            assertEquals(stepper.getCurrentStep(), step);
            // Check Next Event
            assertTrue(isNextFired[0]);
        }

        // Previous Step Test
        final int lastStepIndex = stepper.getWidgetCount();
        stepper.goToStep(lastStepIndex); // Go to last step
        assertEquals(stepper.getCurrentStep(), stepper.getWidget(lastStepIndex - 1));
        for (int i = stepper.getWidgetCount() - 1; i > 0; i--) {
            final boolean[] isPreviousFired = {false};
            stepper.addPreviousHandler(event -> {
                isPreviousFired[0] = true;
            });

            stepper.prevStep();
            assertTrue(stepper.getWidget(i - 1) instanceof MaterialStep);
            MaterialStep step = (MaterialStep) stepper.getWidget(i - 1);
            assertEquals(stepper.getCurrentStep(), step);
            // Check Previous Event
            assertTrue(isPreviousFired[0]);
        }

        // Check Complete Event
        final boolean[] isCompleteFired = {false};
        stepper.addCompleteHandler(event -> {
            isCompleteFired[0] = true;
        });
        stepper.goToStep(lastStepIndex);
        stepper.nextStep();
        assertTrue(isCompleteFired[0]);

        // Reset the Stepper
        stepper.reset();
        assertEquals(stepper.getCurrentStepIndex(), 0);
        assertEquals(stepper.getWidget(0), stepper.getCurrentStep());
    }
{'fraction_non_alphanumeric': 0.10938074800735745, 'fraction_numerical': 0.008828939301042305, 'mean_word_length': 2.7706888580674986, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '680823', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2263, 'n_words': 520}