Esempio n. 1
0
        public static void DefineScript()
        {
            sap.ui.define(new string[] {
                "manu/toolpageapp/fv/model/formatter",
                "sap/ui/thirdparty/sinon",
                "sap/ui/thirdparty/sinon-qunit"
            },
                          new Action <Formatter>(
                              (formatter) => {
                var testObj       = new TestFormatter();
                testObj.formatter = formatter;

                QUnit.module("homeImages", new Hooks()
                {
                    beforeEach = (Assert assert) => {
                        testObj.formatter = formatter;
                    }
                });

                QUnit.test("Should display the reduced image on small screen sizes", (Assert assert) => {
                    testObj.imageSourceTestCase(assert, true, "/images/homeImage_small.jpg");
                });

                QUnit.test("Should display the original image on large screen sizes", (Assert assert) => {
                    testObj.imageSourceTestCase(assert, false, "/images/homeImage.jpg");
                });
            }
                              )
                          );
        }
Esempio n. 2
0
        public static void Script()
        {
            sap.ui.require(new string[] {
                "sap/ui/test/opaQunit",
                "sap/ui/demo/walkthrough/test/integration/pages/app"
            },
                           new Action(() => {
                QUnit.module("Navigation");

                TestsGlobals.opaTest("Should open the hello dialog",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    // Arrangements
                    Given.iStartMyAppInAFrame(sap.ui.require_toUrl("sap/ui/demo/walkthrough/test/mockserver") + ".html");

                    // Actions
                    When.Get <OnTheAppPage>().iPressTheSayHelloWithDialogButton();

                    // Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeTheHelloDialog();

                    // Cleanup
                    Then.Get <OnTheAppPage>().iTeardownMyAppFrame();
                }
                                     );
            })
                           );
        }
Esempio n. 3
0
        public static void Script()
        {
            sap.ui.require(new string[] {
                "sap/ui/demo/walkthrough/model/formatter",
                "sap/ui/model/resource/ResourceModel",
                "sap/ui/thirdparty/sinon",
                "sap/ui/thirdparty/sinon-qunit"
            },
                           new Action <Formatter>(
                               (formatter) => {
                sap.ui.model.resource.ResourceModel oResourceModel = null;

                QUnit.module("Test Module", new Hooks()
                {
                    beforeEach = (Assert assert) => {
                        oResourceModel = new sap.ui.model.resource.ResourceModel(new sap.ui.model.resource.ResourceModel.ResourceModelInfo()
                        {
                            bundleUrl = jQuery.sap.getModulePath("sap.ui.demo.walkthrough", "/i18n/i18n.properties")
                        });
                    },
                    afterEach = (Assert assert) => {
                        oResourceModel.destroy();
                    }
                });

                QUnit.test("Should return the translated texts",
                           (Assert assert) => {
                    // Arrange
                    var oModel = This.Instance.As <FormatterTests>().stub();
                    oModel.withArgs("i18n").As <SinonStub>().returns(oResourceModel);
                    var oViewStub = new {
                        getModel = oModel
                    };
                    var oControllerStub = new {
                        getView = This.Instance.As <FormatterTests>().stub().returns(oViewStub)
                    };

                    // System under test
                    var fnIsolatedFormatter = Globals.BindMethod <Func <string, string> >(formatter, nameof(formatter.statusText), oControllerStub);

                    assert.strictEqual(fnIsolatedFormatter("A"), "New", "The long text for status A is correct");
                    assert.strictEqual(fnIsolatedFormatter("B"), "In Progress", "The long text for status B is correct");
                    assert.strictEqual(fnIsolatedFormatter("C"), "Done", "The long text for status C is correct");
                    assert.strictEqual(fnIsolatedFormatter("Foo"), "Foo", "The long text for status Foo is correct");
                }
                           );
            }
                               )
                           );
        }
        public static void DefineScript()
        {
            sap.ui.define(new string[] {
                "manu/toolpageapp/fv/model/models",
                "sap/ui/thirdparty/sinon",
                "sap/ui/thirdparty/sinon-qunit"
            },
                          new Action <Models>(
                              (models) => {
                var testObj    = new TestModels();
                testObj.models = models;

                QUnit.module("createDeviceModel", new Hooks()
                {
                    afterEach = (Assert assert) => {
                        testObj.oDeviceModel.destroy();
                    }
                });

                QUnit.test("Should initialize a device model for desktop", (Assert assert) => {
                    testObj.isPhoneTestCase(assert, false);
                });

                QUnit.test("Should initialize a device model for phone", (Assert assert) => {
                    testObj.isPhoneTestCase(assert, true);
                });

                QUnit.test("Should initialize a device model for non touch devices", (Assert assert) => {
                    testObj.isTouchTestCase(assert, false);
                });

                QUnit.test("Should initialize a device model for touch devices", (Assert assert) => {
                    testObj.isTouchTestCase(assert, true);
                });

                QUnit.test("The binding mode of the device model should be one way", (Assert assert) => {
                    // System under test
                    testObj.oDeviceModel = new Models().createDeviceModel();

                    // Assert
                    assert.strictEqual(testObj.oDeviceModel.getDefaultBindingMode(), sap.ui.model.BindingMode.OneWay, "Binding mode is correct");
                });
            }
                              )
                          );
        }
Esempio n. 5
0
        public static void Script()
        {
            sap.ui.require(new string[] {
                "sap/ui/test/opaQunit"
            },
                           new Action(() => {
                QUnit.module("Navigation");

                TestsGlobals.opaTest("Should open the hello dialog",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    // Arrangements
                    Given.iStartMyAppInAFrame(jQuery.sap.getResourcePath("sap/ui/demo/app/test", ".html"));

                    //Actions
                    When.Get <OnTheAppPage>().iPressTheSayHelloWithDialogButton();

                    // Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeTheHelloDialog();
                    Then.Get <OnTheAppPage>().iTeardownMyAppFrame();
                }
                                     );
            })
                           );
        }
Esempio n. 6
0
        public static void DefineScript()
        {
            sap.ui.define(new string[] {
                "sap/ui/test/opaQunit",
            },
                          new Action(() => {
                QUnit.module("Desktop navigation");

                TestsGlobals.opaTest("should press the error button and see a popover message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Arrangements
                    Given.As <Common>().iStartTheApp();

                    //Actions
                    When.Get <OnTheAppPage>().iPressTheErrorButton();

                    //Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeTheErrorPopover();
                }
                                     );

                TestsGlobals.opaTest("should press the notification button and see a popover message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheNotificationButton();

                    //Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeTheNotificationPopover();
                }
                                     );

                TestsGlobals.opaTest("should press the user button and see a popover message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheUserButton();

                    //Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeTheUserPopover();
                }
                                     );

                TestsGlobals.opaTest("should press the settings button and navigate to settings view",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheSettingsButton();

                    //Assertions
                    Then.Get <OnTheSettingsPage>().iShouldSeeMasterSettingsView();
                    Then.Get <OnTheSettingsPage>().iShouldSeeDetailSettingsView();
                }
                                     );

                TestsGlobals.opaTest("should press the order settings item and see a toast message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheSettingsPage>().iPressTheOrderSettingsItem();

                    //Assertions
                    Then.Get <OnTheSettingsPage>().iShouldSeeMessageToast();
                }
                                     );

                TestsGlobals.opaTest("should press the save button  and see a toast message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheSettingsPage>().iPressTheSaveButton();

                    //Assertions
                    Then.Get <OnTheSettingsPage>().iShouldSeeMessageToast();
                }
                                     );

                TestsGlobals.opaTest("should press the cancel button  and see a toast message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheSettingsPage>().iPressTheCancelButton();

                    //Assertions
                    Then.Get <OnTheSettingsPage>().iShouldSeeMessageToast();
                }
                                     );

                TestsGlobals.opaTest("should press the statistics button and navigate to statistics view",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheStatisticsButton();

                    //Assertions
                    Then.Get <OnTheStatisticsPage>().iShouldSeeTheStatisticsView();
                    Then.Get <OnTheStatisticsPage>().iShouldSeeTheCharts();
                }
                                     );

                TestsGlobals.opaTest("should press the refresh button",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheStatisticsPage>().iPressTheRefreshButton();

                    //Assertions
                    Then.Get <OnTheStatisticsPage>().iShouldSeeTheBusyIndicator();
                }
                                     );

                TestsGlobals.opaTest("should press the usage statistics button and see a toast message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheUsageStatisticsButton();

                    //Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeMessageToast();
                }
                                     );

                TestsGlobals.opaTest("should press the order statistics button and see a toast message",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheOrderStatisticsButton();

                    //Assertions
                    Then.Get <OnTheAppPage>().iShouldSeeMessageToast();
                }
                                     );

                TestsGlobals.opaTest("should press the home button and navigate to home view",
                                     (sap.ui.test.Opa5 Given, Map <sap.ui.test.Opa5> When, Map <sap.ui.test.Opa5> Then) => {
                    //Actions
                    When.Get <OnTheAppPage>().iPressTheHomeButton();

                    //Assertions
                    Then.Get <OnTheHomePage>().iShouldSeeTheHomeView();
                }
                                     );
            })
                          );
        }