<commit_before>/*
 * Tests for the Windows 10 Desktop Background Settings Handler
 *
 * Copyright 2018 Raising the Floor - US
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/GPII/universal/blob/master/LICENSE.txt
 */

"use strict";

var fluid = require("gpii-universal"),
    jqUnit = require("node-jqunit"),
    path = require("path"),
    fs = require("fs"),
    handler = fluid.registerNamespace("gpii.windows.desktopBackgroundSettingsHandler");

require("../src/desktopBackgroundSettingsHandler.js");

jqUnit.test("Testing 'set' request building for systemSettingsHandler", function () {
    jqUnit.expect(1 + 6 + 1);
    var mode = "set";

    var solidColorPayload = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 0, g: 0, b: 0 }
            }
        }
    };

    var solidColorRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Solid color"
            }
        }
    };

    jqUnit.assertDeepEq("Solid color payload", solidColorRequest, handler.buildSystemSettingsRequest(solidColorPayload, mode)[0]);

    var scalingTypes = ["Fill", "Fit", "Stretch", "Tile", "Center", "Span"];

    var picturePayload = {
        BackgroundType: {
            value: "Picture"
        },
        Input: {
            value: {
                Scaling: undefined,
                Image: "ImagePath"
            }
        }
    };

    var pictureRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Picture"
            },
            SystemSettings_Personalize_Background_ChooseFit: {
                value: undefined
            }
        }
    };

    for (var i = 0; i < scalingTypes.length; i++) {
        picturePayload.Input.value.Scaling = scalingTypes[i];
        pictureRequest.settings.SystemSettings_Personalize_Background_ChooseFit.value = scalingTypes[i];

        jqUnit.assertDeepEq("Picture payload", pictureRequest, handler.buildSystemSettingsRequest(picturePayload, mode)[0]);
    }

    var slideShowPayload = {
        BackgroundType: {
            value: "Slideshow"
        },
        Input: {
            value: {
                Shuffle: true
            }
        }
    };

    var slideShowRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Slideshow"
            },
            SystemSettings_Personalize_Background_SlideshowShuffle: {
                value: true
            }
        }
    };

    jqUnit.assertDeepEq("Slideshow payload", slideShowRequest, handler.buildSystemSettingsRequest(slideShowPayload, mode)[0]);
});

jqUnit.test("Testing 'get' request building for systemSettingsHandler", function () {
    jqUnit.expect(3);
    var mode = "get";

    var solidColorPayload = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 0, g: 0, b: 0 }
            }
        }
    };

    var solidColorRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {}
        }
    };

    jqUnit.assertDeepEq("Solid color payload", solidColorRequest, handler.buildSystemSettingsRequest(solidColorPayload, mode)[0]);

    var picturePayload = {
        BackgroundType: {
            value: "Picture"
        },
        Input: {
            value: {
                Scaling: "Fill",
                Image: "ImagePath"
            }
        }
    };

    var pictureRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {},
            SystemSettings_Personalize_Background_ChooseFit: {}
        }
    };

    jqUnit.assertDeepEq("Picture payload", pictureRequest, handler.buildSystemSettingsRequest(picturePayload, mode)[0]);

    var slideShowPayload = {
        BackgroundType: {
            value: "Slideshow"
        },
        Input: {
            value: {
                Shuffle: true
            }
        }
    };

    var slideShowRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {},
            SystemSettings_Personalize_Background_SlideshowShuffle: {}
        }
    };

    jqUnit.assertDeepEq("Slideshow payload", slideShowRequest, handler.buildSystemSettingsRequest(slideShowPayload, mode)[0]);
});

jqUnit.asyncTest("Set desktop wallpaper using spiSettingsHandler", function () {
    jqUnit.expect(2);

    var pWallRes = handler.getDeskWallpaper();

    pWallRes.then(
        function (res) {
            var curWallpaper = res.value;
            var sysFolder =  "C:\\Windows\\Web\\Wallpaper\\Theme1";
            var curName = path.basename(curWallpaper);

            fs.readdir(sysFolder, function (err, items) {
                if (err) {
                    jqUnit.fail("Problem while reading wallpapers directory content");
                    jqUnit.start();
                } else {
                    var newName = items.find(function (item) { return (item !== curName) && (path.extname(item) === ".jpg"); });
                    if (newName === undefined) {
                        jqUnit.fail("Not able to find another picture to replace actual wallpaper");
                        jqUnit.start();
                    } else {
                        var newWallpaper = path.join(sysFolder, newName);

                        handler.setDeskWallpaper(newWallpaper).then(
                            function () {
                                jqUnit.assert("Wallpaper set correctly");

                                handler.setDeskWallpaper(curWallpaper).then(
                                    function () {
                                        jqUnit.assert("Recovered original wallpaper");
                                        jqUnit.start();
                                    },
                                    function () {
                                        jqUnit.fail("Failed to recover original wallpaper");
                                        jqUnit.start();
                                    }
                                );
                            },
                            function () {
                                jqUnit.fail("Error while setting wallpaper");
                                jqUnit.start();
                            }
                        );
                    }
                }
            });
        },
        function () {
            jqUnit.fail("Failed to get current wallpaper");
            jqUnit.start();

        }
    );
});

jqUnit.test("Test setting system colors for desktop", function () {
    jqUnit.expect(3);

    var newColor = { r: 96, g: 85, b: 78 };
    var curColor = handler.getSolidColor();

    var setColorRes = handler.setSolidColor(newColor);
    jqUnit.assertTrue("setSolidColor: Should return 'true'", setColorRes);

    var newSettedColor = handler.getSolidColor();
    jqUnit.assertEquals("setSolidColor: Color should be now the new setted color", newColor, newSettedColor);

    // Restore previous system color
    var restRes = handler.setSolidColor(curColor);
    jqUnit.assertTrue("Restoring original system color should succeed", restRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'SolidColor' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var sysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            value: "Solid color"
        }
    };

    var results = {
        values: {
            color: { r: 96, g: 85, b: 78 }
        }
    };

    var sysMapRes = handler.mapSystemResults(sysResults, "get");
    var mapRes = handler.addInputVals(results, sysMapRes[0], "get");

    var expRes = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 96, g: 85, b: 78 }
            }
        }
    };

    jqUnit.assertDeepEq("'Solid Color' map result", expRes, mapRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'SolidColor-Picture' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var picSysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            oldValue: {
                value: "Solid color"
            },
            newValue: {
                value: "Picture"
            }
        },
        SystemSettings_Personalize_Background_ChooseFit: {
            oldValue: {
                value: "Stretch"
            },
            newValue: {
                value: "Fill"
            }
        }
    };

    var picResults = {
        oldValues: {
            color: { r: 127, g: 201, b: 18 }
        },
        newValues: {
            image: "IMG2"
        }
    };

    var sysMapRes = handler.mapSystemResults(picSysResults, "set");
    var mapRes = handler.addInputVals(picResults, sysMapRes[0], "set");

    var expRes = {
        BackgroundType: {
            oldValue: {
                value: "SolidColor"
            },
            newValue: {
                value: "Picture"
            }
        },
        Input: {
            oldValue: {
                value: {
                    Color: { r: 127, g: 201, b: 18 }
                }
            },
            newValue: {
                value: {
                    Scaling: "Fill",
                    Image: "IMG2"
                }
            }
        }
    };

    jqUnit.assertDeepEq("'Picture' map result", expRes, mapRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'Picture-Slideshow' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var slideshowSysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            oldValue: {
                value: "Picture"
            },
            newValue: {
                value: "Slideshow"
            }
        },
        SystemSettings_Personalize_Background_ChooseFit: {
            oldValue: {
                value: "Fill"
            },
            newValue: {
                value: ""
            }
        },
        SystemSettings_Personalize_Background_SlideshowShuffle: {
            oldValue: {
                value: false
            },
            newValue: {
                value: true
            }
        }
    };

    var slideshowRes = {
        oldValues: {
            image: "IMG2"
        }
    };

    var sysMapRes = handler.mapSystemResults(slideshowSysResults, "set");
    var mapRes = handler.addInputVals(slideshowRes, sysMapRes[0], "set");

    var expRes = {
        BackgroundType: {
            oldValue: {
                value: "Picture"
            },
            newValue: {
                value: "Slideshow"
            }
        },
        Input: {
            oldValue: {
                value: {
                    Image: "IMG2",
                    Scaling: "Fill"
                }
            },
            newValue: {
                value: {
                    Shuffle: true
                }
            }
        }
    };

    jqUnit.assertDeepEq("'Slideshow' map result", expRes, mapRes);
});

jqUnit.asyncTest("Testing desktopBackgroundSettingsHandler setter functionality", function () {
    jqUnit.expect(0);

    var newSettings = {
        settings: {
            BackgroundType: {
                value: "SolidColor"
            },
            Input: {
                value: {
                    Color: { r: 67, g: 187, b: 19 }
                }
            }
        },
        options: {}
    };

    var getRequestMode = {
        settings: {
            BackgroundType: {}
        },
        options: {}
    };

    var getAndSet = function (getRequest) {
        var curValuesP = handler.getImpl(getRequest);
        curValuesP.then(
            function (curValues) {
                var pSet = handler.setImpl(newSettings);

                pSet.then(
                    function () {
                        var newRequest = { settings: curValues, options: {} };
                        var recP = handler.setImpl(newRequest);

                        recP.then (
                            function () {
                                jqUnit.start();
                            },
                            function (err) {
                                jqUnit.fail(err);
                                jqUnit.start();
                            }
                        );
                    }
                );
            },
            function (err) {
                jqUnit.fail(err);
                jqUnit.start();
            }
        );
    };

    var oldModeP = handler.getImpl(getRequestMode);
    oldModeP.then(
        function (curValues) {
            var curBackType = curValues.BackgroundType.value;

            if (curBackType === "SolidColor") {
                var getColorReq = {
                    settings: {
                        BackgroundType: {
                            value: "SolidColor"
                        },
                        Input: {
                            value: {
                                Color: undefined
                            }
                        }
                    },
                    options: {}
                };

                getAndSet(getColorReq);
            } else if (curBackType === "Picture") {
                var getPictureReq = {
                    settings: {
                        BackgroundType: {
                            value: "Picture"
                        },
                        Input: {
                            value: {
                                Image: undefined,
                                Scaling: undefined
                            }
                        }
                    },
                    options: {}
                };

                getAndSet(getPictureReq);
            } else if (curBackType === "Slideshow") {
                var getSlideshow = {
                    settings: {
                        BackgroundType: {
                            value: "Slideshow"
                        },
                        Input: {
                            value: {
                                Shuffle: undefined
                            }
                        }
                    },
                    options: {}
                };

                getAndSet(getSlideshow);
            }
        },
        function (err) {
            jqUnit.fail(err);
            jqUnit.start();
        }
    );
});<commit_msg>GPII-2809: Tests improved using multiple payload and new settingsHandler changes<commit_after>/*
 * Tests for the Windows 10 Desktop Background Settings Handler
 *
 * Copyright 2018 Raising the Floor - US
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/GPII/universal/blob/master/LICENSE.txt
 */

"use strict";

var fluid = require("gpii-universal"),
    jqUnit = require("node-jqunit"),
    path = require("path"),
    fs = require("fs");

var windows = fluid.registerNamespace("gpii.windows"),
    handler = fluid.registerNamespace("gpii.windows.desktopBackground");

require("../src/desktopBackgroundSettingsHandler.js");

jqUnit.test("Testing 'set' request building for systemSettingsHandler", function () {
    jqUnit.expect(1 + 6 + 1);
    var mode = "set";

    var solidColorPayload = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 0, g: 0, b: 0 }
            }
        }
    };

    var solidColorRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Solid color"
            }
        }
    };

    jqUnit.assertDeepEq("Solid color payload", solidColorRequest, handler.buildSystemSettingsRequest(solidColorPayload, mode)[0]);

    var scalingTypes = ["Fill", "Fit", "Stretch", "Tile", "Center", "Span"];

    var picturePayload = {
        BackgroundType: {
            value: "Picture"
        },
        Input: {
            value: {
                Scaling: undefined,
                Image: "ImagePath"
            }
        }
    };

    var pictureRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Picture"
            },
            SystemSettings_Personalize_Background_ChooseFit: {
                value: undefined
            }
        }
    };

    for (var i = 0; i < scalingTypes.length; i++) {
        picturePayload.Input.value.Scaling = scalingTypes[i];
        pictureRequest.settings.SystemSettings_Personalize_Background_ChooseFit.value = scalingTypes[i];

        jqUnit.assertDeepEq("Picture payload", pictureRequest, handler.buildSystemSettingsRequest(picturePayload, mode)[0]);
    }

    var slideShowPayload = {
        BackgroundType: {
            value: "Slideshow"
        },
        Input: {
            value: {
                Shuffle: true
            }
        }
    };

    var slideShowRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {
                value: "Slideshow"
            },
            SystemSettings_Personalize_Background_SlideshowShuffle: {
                value: true
            }
        }
    };

    jqUnit.assertDeepEq("Slideshow payload", slideShowRequest, handler.buildSystemSettingsRequest(slideShowPayload, mode)[0]);
});

jqUnit.test("Testing 'get' request building for systemSettingsHandler", function () {
    jqUnit.expect(3);
    var mode = "get";

    var solidColorPayload = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 0, g: 0, b: 0 }
            }
        }
    };

    var solidColorRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {}
        }
    };

    jqUnit.assertDeepEq("Solid color payload", solidColorRequest, handler.buildSystemSettingsRequest(solidColorPayload, mode)[0]);

    var picturePayload = {
        BackgroundType: {
            value: "Picture"
        },
        Input: {
            value: {
                Scaling: "Fill",
                Image: "ImagePath"
            }
        }
    };

    var pictureRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {},
            SystemSettings_Personalize_Background_ChooseFit: {}
        }
    };

    jqUnit.assertDeepEq("Picture payload", pictureRequest, handler.buildSystemSettingsRequest(picturePayload, mode)[0]);

    var slideShowPayload = {
        BackgroundType: {
            value: "Slideshow"
        },
        Input: {
            value: {
                Shuffle: true
            }
        }
    };

    var slideShowRequest = {
        settings: {
            SystemSettings_Personalize_Background_ChooseBackground: {},
            SystemSettings_Personalize_Background_SlideshowShuffle: {}
        }
    };

    jqUnit.assertDeepEq("Slideshow payload", slideShowRequest, handler.buildSystemSettingsRequest(slideShowPayload, mode)[0]);
});

jqUnit.asyncTest("Set desktop wallpaper using spiSettingsHandler", function () {
    jqUnit.expect(2);

    var curWallpaper = handler.getDeskWallpaper().value;
    var sysFolder =  "C:\\Windows\\Web\\Wallpaper\\Theme1";
    var curName = path.basename(curWallpaper);

    fs.readdir(sysFolder, function (err, items) {
        if (err) {
            jqUnit.fail("Problem while reading wallpapers directory content");
            jqUnit.start();
        } else {
            var newName = items.find(function (item) { return (item !== curName) && (path.extname(item) === ".jpg"); });
            if (newName === undefined) {
                jqUnit.fail("Not able to find another picture to replace actual wallpaper");
                jqUnit.start();
            } else {
                var newWallpaper = path.join(sysFolder, newName);

                handler.setDeskWallpaper(newWallpaper).then(
                    function () {
                        jqUnit.assert("Wallpaper set correctly");

                        if (curWallpaper === "") {
                            jqUnit.assert("Recovered original wallpaper");
                            jqUnit.start();
                        } else {
                            handler.setDeskWallpaper(curWallpaper).then(
                                function () {
                                    jqUnit.assert("Recovered original wallpaper");
                                    jqUnit.start();
                                },
                                function () {
                                    jqUnit.fail("Failed to recover original wallpaper");
                                    jqUnit.start();
                                }
                            );
                        }
                    },
                    function () {
                        jqUnit.fail("Error while setting wallpaper");
                        jqUnit.start();
                    }
                );
            }
        }
    });
});

jqUnit.test("Test setting system colors for desktop", function () {
    jqUnit.expect(3);

    var newColor = { r: 96, g: 85, b: 78 };
    var curColor = windows.getSolidColor();

    var setColorRes = windows.setSolidColor(newColor);
    jqUnit.assertTrue("setSolidColor: Should return 'true'", setColorRes);

    var newSettedColor = windows.getSolidColor();
    jqUnit.assertDeepEq("setSolidColor: Color should be now the new setted color", newColor, newSettedColor);

    // Restore previous system color
    var restRes = windows.setSolidColor(curColor);
    jqUnit.assertTrue("Restoring original system color should succeed", restRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'SolidColor' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var sysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            value: "Solid color"
        }
    };

    var results = {
        values: {
            color: { r: 96, g: 85, b: 78 }
        }
    };

    var sysMapRes = handler.mapSystemResults(sysResults, "get");
    var mapRes = handler.addInputVals(results, sysMapRes[0], "get");

    var expRes = {
        BackgroundType: {
            value: "SolidColor"
        },
        Input: {
            value: {
                Color: { r: 96, g: 85, b: 78 }
            }
        }
    };

    jqUnit.assertDeepEq("'Solid Color' map result", expRes, mapRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'SolidColor-Picture' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var picSysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            oldValue: {
                value: "Solid color"
            },
            newValue: {
                value: "Picture"
            }
        },
        SystemSettings_Personalize_Background_ChooseFit: {
            oldValue: {
                value: "Stretch"
            },
            newValue: {
                value: "Fill"
            }
        }
    };

    var picResults = {
        oldValues: {
            color: { r: 127, g: 201, b: 18 }
        },
        newValues: {
            image: "IMG2"
        }
    };

    var sysMapRes = handler.mapSystemResults(picSysResults, "set");
    var mapRes = handler.addInputVals(picResults, sysMapRes[0], "set");

    var expRes = {
        BackgroundType: {
            oldValue: {
                value: "SolidColor"
            },
            newValue: {
                value: "Picture"
            }
        },
        Input: {
            oldValue: {
                value: {
                    Color: { r: 127, g: 201, b: 18 }
                }
            },
            newValue: {
                value: {
                    Scaling: "Fill",
                    Image: "IMG2"
                }
            }
        }
    };

    jqUnit.assertDeepEq("'Picture' map result", expRes, mapRes);
});

jqUnit.test("Testing desktopBackgroundSettingsHandler 'Picture-Slideshow' mapping from systemSettingsHandler results", function () {
    jqUnit.expect(1);

    var slideshowSysResults = {
        SystemSettings_Personalize_Background_ChooseBackground: {
            oldValue: {
                value: "Picture"
            },
            newValue: {
                value: "Slideshow"
            }
        },
        SystemSettings_Personalize_Background_ChooseFit: {
            oldValue: {
                value: "Fill"
            },
            newValue: {
                value: ""
            }
        },
        SystemSettings_Personalize_Background_SlideshowShuffle: {
            oldValue: {
                value: false
            },
            newValue: {
                value: true
            }
        }
    };

    var slideshowRes = {
        oldValues: {
            image: "IMG2"
        }
    };

    var sysMapRes = handler.mapSystemResults(slideshowSysResults, "set");
    var mapRes = handler.addInputVals(slideshowRes, sysMapRes[0], "set");

    var expRes = {
        BackgroundType: {
            oldValue: {
                value: "Picture"
            },
            newValue: {
                value: "Slideshow"
            }
        },
        Input: {
            oldValue: {
                value: {
                    Image: "IMG2",
                    Scaling: "Fill"
                }
            },
            newValue: {
                value: {
                    Shuffle: true
                }
            }
        }
    };

    jqUnit.assertDeepEq("'Slideshow' map result", expRes, mapRes);
});

jqUnit.asyncTest("Testing desktopBackgroundSettingsHandler setter functionality with payload", function () {
    jqUnit.expect(0);

    var payloads = [
        {
            newSettings: {
                settings: {
                    BackgroundType: {
                        value: "SolidColor"
                    },
                    Input: {
                        value: {
                            Color: { r: 67, g: 187, b: 19 }
                        }
                    }
                },
                options: {}
            },
            getRequest: {
                settings: {
                    BackgroundType: {}
                },
                options: {}
            }
        },
        {
            newSettings: {
                settings: {
                    BackgroundType: {
                        value: "Picture"
                    },
                    Input: {
                        value: {
                            Scaling: "Fill",
                            Image: "C:\\Windows\\Web\\Wallpaper\\Theme1\\img1.jpg"
                        }
                    }
                },
                options: {}
            },
            getRequest: {
                settings: {
                    BackgroundType: {
                        value: "Picture"
                    },
                    Input: {
                        value: {
                            Scaling: undefined,
                            Image: undefined
                        }
                    }
                },
                options: {}
            }
        },
        {
            newSettings: {
                settings: {
                    BackgroundType: {
                        value: "Slideshow"
                    },
                    Input: {
                        value: {
                            Shuffle: true
                        }
                    }
                },
                options: {}
            },
            getRequest: {
                settings: {
                    BackgroundType: {
                        value: "Slideshow"
                    },
                    Input: {
                        value: {
                            Shuffle: undefined
                        }
                    }
                },
                options: {}
            }
        }
    ];

    var getAndSet = function (getRequest, newSettings) {
        var curValuesP = handler.getImpl(getRequest);
        curValuesP.then(
            function (curValues) {
                var pSet = handler.setImpl(newSettings);

                pSet.then(
                    function () {
                        var newRequest = { settings: curValues, options: {} };
                        var recP = handler.setImpl(newRequest);

                        recP.then (
                            function () {
                                jqUnit.start();
                            },
                            function (err) {
                                jqUnit.fail(err);
                                jqUnit.start();
                            }
                        );
                    }
                );
            },
            function (err) {
                jqUnit.fail(err);
                jqUnit.start();
            }
        );
    };

    fluid.each(payloads, function (payload) {
        var newSettings = payload.newSettings;
        var getRequest = payload.getRequest;

        var oldModeP = handler.getImpl(getRequest);

        oldModeP.then(
            function (curValues) {
                var curBackType = curValues.BackgroundType.value;

                if (curBackType === "SolidColor") {
                    var getColorReq = {
                        settings: {
                            BackgroundType: {
                                value: "SolidColor"
                            },
                            Input: {
                                value: {
                                    Color: undefined
                                }
                            }
                        },
                        options: {}
                    };

                    getAndSet(getColorReq, newSettings);
                } else if (curBackType === "Picture") {
                    var getPictureReq = {
                        settings: {
                            BackgroundType: {
                                value: "Picture"
                            },
                            Input: {
                                value: {
                                    Image: undefined,
                                    Scaling: undefined
                                }
                            }
                        },
                        options: {}
                    };

                    getAndSet(getPictureReq, newSettings);
                } else if (curBackType === "Slideshow") {
                    var getSlideshow = {
                        settings: {
                            BackgroundType: {
                                value: "Slideshow"
                            },
                            Input: {
                                value: {
                                    Shuffle: undefined
                                }
                            }
                        },
                        options: {}
                    };

                    getAndSet(getSlideshow, newSettings);
                }
            },
            function (err) {
                jqUnit.fail(err);
                jqUnit.start();
            }
        );
    });
});
{'fraction_non_alphanumeric': 0.095369211514393, 'fraction_numerical': 0.005068836045056321, 'mean_word_length': 1.1582145992301978, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5741858', 'n_tokens_mistral': 8277, 'n_tokens_neox': 7500, 'n_words': 1495}