text:
/**
 * @brief covers API from ewk_text_checker.h
 * @file test_ewk2_text_checker.cpp
 */

#include "config.h"

#include "UnitTestUtils/EWK2UnitTestBase.h"
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>

using namespace EWK2UnitTest;

extern EWK2UnitTestEnvironment* environment;

static const uint64_t defaultDocumentTag = 123;
static const char expectedMisspelledWord[] = "aa";
static const Evas_Object* defaultView = 0;
static bool isSettingEnabled = false;
static Ecore_Timer* timeoutTimer = 0;
static double defaultTimeoutInSeconds = 0.5;

static bool wasContextMenuShown = false;

static const char* clientSuggestionsForWord[] = { "clientSuggestion1", "clientSuggestion2", "clientSuggestion3" };
static unsigned contextMenuItemsNumber = 0;
static String knownWord;

/**
 * Structure keeps information which callbacks were called.
 * Its values are reset before each test.
 */
static struct {
    bool settingChange;
    bool spellDocumentTag;
    bool spellDocumentTagClose;
    bool spellingCheck;
    bool wordGuesses;
    bool wordLearn;
    bool wordIgnore;
} callbacksExecutionStats;

class EWK2TextCheckerTest : public EWK2UnitTestBase {
public:
    static void resetCallbacksExecutionStats()
    {
        callbacksExecutionStats.settingChange = false;
        callbacksExecutionStats.spellDocumentTag = false;
        callbacksExecutionStats.spellDocumentTagClose = false;
        callbacksExecutionStats.spellingCheck = false;
        callbacksExecutionStats.wordGuesses = false;
        callbacksExecutionStats.wordLearn = false;
        callbacksExecutionStats.wordIgnore = false;
    }

    /**
     * Handle the timeout, it may happen for the asynchronous tests.
     *
     * @internal
     *
     * @return the ECORE_CALLBACK_CANCEL flag to delete the timer automatically
     */
    static Eina_Bool onTimeout(void*)
    {
        ecore_main_loop_quit();
        return ECORE_CALLBACK_CANCEL;
    }

    /**
     * This callback tests whether the client's callback is called when the spell checking setting was changed.
     *
     * @internal
     *
     * Verify the new setting value (passes in the @a flag parameter) if it equals to the previously set.
     *
     * @internal
     *
     * @param flag the new setting value
     */
    static void onSettingChange(Eina_Bool flag)
    {
        EXPECT_EQ(isSettingEnabled, flag);
        callbacksExecutionStats.settingChange = true;
    }

    /**
     * Returns unique tag (an identifier).
     *
     * @internal
     *
     * It will be used for onSpellingCheck, onWordGuesses etc. to notify
     * the client on which object (associated to the tag) the spelling is being invoked.
     *
     * @param ewkView the view object to get unique tag
     *
     * @return unique tag for the given @a ewkView object
     */
    static uint64_t onSpellDocumentTag(const Evas_Object* ewkView)
    {
        EXPECT_EQ(defaultView, ewkView);
        callbacksExecutionStats.spellDocumentTag = true;

        return defaultDocumentTag;
    }

    /**
     * The view which is associated to the @a tag has been destroyed.
     *
     * @internal
     *
     * @param tag the tag to be closed
     */
    static void onSpellDocumentTagClose(uint64_t tag)
    {
        ASSERT_EQ(defaultDocumentTag, tag);
        callbacksExecutionStats.spellDocumentTagClose = true;
    }

    /**
     * Checks spelling for the given @a text.
     *
     * @internal
     *
     * @param tag unique tag to notify the client on which object the spelling is being performed
     * @param text the text containing the words to spellcheck
     * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct
     * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct
     */
    static void onSpellingCheck(uint64_t tag, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
    {
        ASSERT_EQ(defaultDocumentTag, tag);
        ASSERT_STREQ(expectedMisspelledWord, text);

        ASSERT_TRUE(misspellingLocation);
        ASSERT_TRUE(misspellingLength);

        // The client is able to show the misselled text through its location (the beginning of misspelling)
        // and length (the end of misspelling).
        *misspellingLocation = 0;
        *misspellingLength = strlen(expectedMisspelledWord);

        callbacksExecutionStats.spellingCheck = true;
    }

    /**
     * Checks spelling for the given @a text and compares it with the knownWord.
     *
     * @internal
     *
     * @param text the text containing the words to spellcheck
     * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct
     * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct
     */
    static void onSpellingForKnownWord(uint64_t, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
    {
        ASSERT_STREQ(knownWord.utf8().data(), text);

        ASSERT_TRUE(misspellingLocation);
        ASSERT_TRUE(misspellingLength);

        *misspellingLocation = -1;
        *misspellingLength = 0;

        callbacksExecutionStats.spellingCheck = true;
    }

    /**
     * Gets a list of suggested spellings for a misspelled @a word.
     *
     * @internal
     *
     * @param tag unique tag to notify the client on which object the spelling is being performed
     * @param word the word to get guesses
     * @return a list of dynamically allocated strings (as char*) and
     *         caller is responsible for destroying them.
     */
    static Eina_List* onWordGuesses(uint64_t tag, const char* word)
    {
        EXPECT_EQ(defaultDocumentTag, tag);
        EXPECT_STREQ(expectedMisspelledWord, word);

        Eina_List* suggestionsForWord = 0;
        size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
        for (size_t i = 0; i < numberOfSuggestions; ++i)
            suggestionsForWord = eina_list_append(suggestionsForWord, strdup(clientSuggestionsForWord[i]));

        callbacksExecutionStats.wordGuesses = true;
        return suggestionsForWord;
    }

    /**
     * Adds the @a word to the spell checker dictionary.
     *
     * @internal
     *
     * @param tag unique tag to notify the client on which object the spelling is being performed
     * @param word the word to add
     */
    static void onWordLearn(uint64_t tag, const char* word)
    {
        ASSERT_EQ(defaultDocumentTag, tag);
        ASSERT_STREQ(expectedMisspelledWord, word);
        knownWord = word;
        callbacksExecutionStats.wordLearn = true;
    }

    /**
     * Tells the spell checker to ignore a given @a word.
     *
     * @internal
     *
     * @param tag unique tag to notify the client on which object the spelling is being performed
     * @param word the word to ignore
     */
    static void onWordIgnore(uint64_t tag, const char* word)
    {
        ASSERT_EQ(defaultDocumentTag, tag);
        ASSERT_STREQ(expectedMisspelledWord, word);
        knownWord = word;
        callbacksExecutionStats.wordIgnore = true;
    }

    /**
     * Helper, get required item from context menu.
     *
     * @param contextMenu the context menu object
     * @param itemAction action of item to get
     * @param itemType type of item to get
     *
     * @return required item
     */
    static Ewk_Context_Menu_Item* findContextMenuItem(const Ewk_Context_Menu* contextMenu, Ewk_Context_Menu_Item_Action itemAction, Ewk_Context_Menu_Item_Type itemType)
    {
        const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);

        void* itemData;
        const Eina_List* listIterator;
        EINA_LIST_FOREACH(contextMenuItems, listIterator, itemData) {
            Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(itemData);
            if (ewk_context_menu_item_action_get(item) == itemAction
                && ewk_context_menu_item_type_get(item) == itemType)
                return item;
        }

        return 0;
    }

    static Eina_Bool checkCorrectnessOfSpellingItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        Ewk_Context_Menu_Item* noGuessesItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_NO_GUESSES_FOUND, EWK_ACTION_TYPE);
        EXPECT_FALSE(noGuessesItem);

        Ewk_Context_Menu_Item* ignoreSpellingItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING, EWK_ACTION_TYPE);
        EXPECT_TRUE(ignoreSpellingItem);

        Ewk_Context_Menu_Item* learnSpellingItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING, EWK_ACTION_TYPE);
        EXPECT_TRUE(learnSpellingItem);

        wasContextMenuShown = true;
        return true;
    }

    static Eina_Bool toogleCheckSpellingWhileTyping(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        Ewk_Context_Menu_Item* spellingAndGrammarItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, EWK_SUBMENU_TYPE);
        EXPECT_TRUE(spellingAndGrammarItem);

        Ewk_Context_Menu* spellingAndGrammarSubmenu = ewk_context_menu_item_submenu_get(spellingAndGrammarItem);
        Ewk_Context_Menu_Item* checkSpellingWhileTypingItem = findContextMenuItem(spellingAndGrammarSubmenu, EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING, EWK_CHECKABLE_ACTION_TYPE);
        EXPECT_TRUE(checkSpellingWhileTypingItem);

        return ewk_context_menu_item_select(spellingAndGrammarSubmenu, checkSpellingWhileTypingItem);
    }

    static Eina_Bool checkClientSuggestionsForWord(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);

        size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
        // contextMenuItems should contain suggestions and another options.
        if (numberOfSuggestions > eina_list_count(contextMenuItems)) {
            ADD_FAILURE();
            return true;
        }
        // Verify suggestions from the top of context menu list.
        for (size_t i = 0; i < numberOfSuggestions; ++i) {
            Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(eina_list_data_get(contextMenuItems));
            EXPECT_STREQ(clientSuggestionsForWord[i], ewk_context_menu_item_title_get(item));
            contextMenuItems = eina_list_next(contextMenuItems);
        }

        wasContextMenuShown = true;
        return true;
    }

    static Eina_Bool selectLearnSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        Ewk_Context_Menu_Item* learnSpellingItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING, EWK_ACTION_TYPE);
        EXPECT_TRUE(learnSpellingItem);

        return ewk_context_menu_item_select(contextMenu, learnSpellingItem);
    }

    static Eina_Bool selectIgnoreSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        Ewk_Context_Menu_Item* ignoreSpellingItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING, EWK_ACTION_TYPE);
        EXPECT_TRUE(ignoreSpellingItem);

        return ewk_context_menu_item_select(contextMenu, ignoreSpellingItem);
    }

    /**
     * Count number of elements in context menu.
     */
    static Eina_Bool countContextMenuItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
    {
        contextMenuItemsNumber = eina_list_count(ewk_context_menu_items_get(contextMenu));
        wasContextMenuShown = true;
        return true;
    }

protected:
    enum Line { FirstLine, SecondLine };
    enum Button { SelectAllWordsWithSpellcheckButton, SelectAllWordsWithoutSpellcheckButton, SelectSubWordWithSpellcheckButton };

    void clickButton(Button button)
    {
        switch (button) {
        case SelectAllWordsWithSpellcheckButton:
            mouseClick(60, 60);
            break;
        case SelectAllWordsWithoutSpellcheckButton:
            mouseClick(500, 60);
            break;
        case SelectSubWordWithSpellcheckButton :
            mouseClick(200, 60);
            break;
        }
    }

    void showContextMenu(Line line)
    {
        switch (line) {
        case FirstLine:
            mouseClick(10, 20, 3);
            break;
        case SecondLine:
            mouseClick(35, 35, 3);
            break;
        }
    }

    void selectFirstWord(Line line)
    {
        switch (line) {
        case FirstLine:
            mouseDoubleClick(10, 20);
            break;
        case SecondLine:
            mouseDoubleClick(35, 35);
            break;
        }
    }
};

/**
 * Test whether there are spelling suggestions when misspelled word is directly context clicked.
 */
TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_context_click)
{
    wasContextMenuShown = false;

    // Checking number of context menu items when element has no spellcheck suggestions.
    ewkViewClass()->context_menu_show = countContextMenuItems;
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;

    wasContextMenuShown = false;

    // Testing how many items are in context menu when spellcheck is enabled.
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    showContextMenu(SecondLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));

    EXPECT_LT(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
}

/**
 * Test whether there are no spelling suggestions when multiple words are selected (that are not a single misspelling).
 */
TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_multiword_selection)
{
    wasContextMenuShown = false;

    // Checking number of context menu items when element has no spellcheck suggestions.
    ewkViewClass()->context_menu_show = countContextMenuItems;
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    clickButton(SelectAllWordsWithoutSpellcheckButton);
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;

    wasContextMenuShown = false;

    // Testing how many items are in context menu when multiple words are selected.
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    clickButton(SelectAllWordsWithSpellcheckButton);
    showContextMenu(SecondLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));

    EXPECT_EQ(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
}

/**
 * Test whether there are no spelling suggestions when part of misspelled word are selected.
 */
TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_subword_selection)
{
    wasContextMenuShown = false;

    // Checking number of context menu items when element has no spellcheck suggestions.
    ewkViewClass()->context_menu_show = countContextMenuItems;
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    clickButton(SelectAllWordsWithoutSpellcheckButton);
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;

    wasContextMenuShown = false;

    // Testing how many items are in context menu when part of word is selected.
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    clickButton(SelectSubWordWithSpellcheckButton);
    showContextMenu(SecondLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));

    EXPECT_EQ(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
}

/**
 * Test whether context menu spelling items are available when misspelled word has selection as the double click.
 */
TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_double_clicked_word)
{
    wasContextMenuShown = false;

    // Checking number of context menu items when element has no spell check suggestions.
    ewkViewClass()->context_menu_show = countContextMenuItems;
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    clickButton(SelectAllWordsWithoutSpellcheckButton);
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;

    wasContextMenuShown = false;

    // Making double click on misspelled word to select it, and checking are there context menu spell check suggestions.
    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    selectFirstWord(SecondLine);
    showContextMenu(SecondLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));

    EXPECT_LT(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
}

/**
 * Test whether the default language is loaded independently of
 * continuous spell checking setting.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages_get)
{
    ewk_text_checker_continuous_spell_checking_enabled_set(false);
    // The language is being loaded on the idler, wait for it.
    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    ecore_main_loop_begin();

    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    // No dictionary is available/installed.
    if (!loadedLanguages)
        return;

    EXPECT_EQ(1, eina_list_count(loadedLanguages));

    void* data;
    EINA_LIST_FREE(loadedLanguages, data)
        eina_stringshare_del(static_cast<Eina_Stringshare*>(data));

    // Repeat the checking when continuous spell checking setting is on.
    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    ecore_main_loop_begin();

    loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    if (!loadedLanguages)
        return;

    EXPECT_EQ(1, eina_list_count(loadedLanguages));

    EINA_LIST_FREE(loadedLanguages, data)
        eina_stringshare_del(static_cast<Eina_Stringshare*>(data));
}

/**
 * Test whether the context menu spelling items (suggestions, learn and ignore spelling)
 * are available when continuous spell checking is off.
 */
TEST_F(EWK2TextCheckerTest, context_menu_spelling_items_availability)
{
    wasContextMenuShown = false;

    ewk_text_checker_continuous_spell_checking_enabled_set(false);
    ewkViewClass()->context_menu_show = checkCorrectnessOfSpellingItems;

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
}

/**
 * Test setter/getter for the continuous spell checking:
 *  - ewk_text_checker_continuous_spell_checking_enabled_get
 *  - ewk_text_checker_continuous_spell_checking_enabled_set
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_enabled)
{
    ewk_text_checker_continuous_spell_checking_enabled_set(true);
#if ENABLE(SPELLCHECK)
    EXPECT_TRUE(ewk_text_checker_continuous_spell_checking_enabled_get());
#else
    EXPECT_FALSE(ewk_text_checker_continuous_spell_checking_enabled_get());
#endif

    ewk_text_checker_continuous_spell_checking_enabled_set(false);
    EXPECT_FALSE(ewk_text_checker_continuous_spell_checking_enabled_get());
}

/**
 * Test whether the onSettingChange callback is called when "Check Spelling While Typing" setting was changed in context menu.
 * Two cases are tested:
 *  - "Check Spelling While Typing" is enabled,
 *  - "Check Spelling While Typing" is disabled.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_check_spelling_while_typing_toggle)
{
    resetCallbacksExecutionStats();
    ewkViewClass()->context_menu_show = toogleCheckSpellingWhileTyping;

    ewk_text_checker_continuous_spell_checking_change_cb_set(onSettingChange);
    isSettingEnabled = !ewk_text_checker_continuous_spell_checking_enabled_get();

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    showContextMenu(FirstLine);
    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));

    resetCallbacksExecutionStats();

    // Test case, when "Check Spelling While Typing" is in reverse to the previous one.
    isSettingEnabled = !isSettingEnabled;

    showContextMenu(FirstLine);
    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));

    ewk_text_checker_continuous_spell_checking_change_cb_set(0);
}

/**
 * Test whether the onSettingChange callback is not called when the spell checking setting was changed by client.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_set)
{
    resetCallbacksExecutionStats();

    ewk_text_checker_continuous_spell_checking_change_cb_set(onSettingChange);

    isSettingEnabled = ewk_text_checker_continuous_spell_checking_enabled_get();
    isSettingEnabled = !isSettingEnabled;
    // The notifications about the setting change shouldn't be sent if the change was made
    // on the client's request (public API).
    ewk_text_checker_continuous_spell_checking_enabled_set(isSettingEnabled);

    // The notification about the change of the spell checking setting is called on idler.
    ASSERT_FALSE(waitUntilTrue(callbacksExecutionStats.settingChange, /*Timeout*/ 0));

    ewk_text_checker_continuous_spell_checking_change_cb_set(0);
}

/**
 * Test whether the onSettingChange callback is not called, if the client does not set it.
 * "Check Spelling While Typing" option is toggled in context menu.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_unset)
{
    resetCallbacksExecutionStats();
    ewkViewClass()->context_menu_show = toogleCheckSpellingWhileTyping;

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    showContextMenu(FirstLine);
    ASSERT_FALSE(waitUntilTrue(callbacksExecutionStats.settingChange, /*Timeout*/ 0));
}

/**
 * This unit test sets all available/installed dictionaries and verifies them
 * if they are in use.
 * All the dictionaries from the list can be set to perform spellchecking.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_available_languages_get)
{
    Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
    // No dictionary is available/installed or the SPELLCHECK macro is disabled.
    if (!availableLanguages)
        return;

    // Helper to create one string with comma separated languages.
    void* actual = 0;
    WTF::StringBuilder languages;
    Eina_List* listIterator = 0;
    unsigned lastIndex = eina_list_count(availableLanguages) - 1;
    unsigned i = 0;
    EINA_LIST_FOREACH(availableLanguages, listIterator, actual) {
        languages.append(static_cast<const char*>(actual));
        // Add the comma after all but the last language IDs.
        if (i++ != lastIndex)
            languages.append(',');
    }

    // Set all available languages.
    ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());

    // Languages are being loaded on the idler, wait for them.
    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    ecore_main_loop_begin();

    // Get the languages in use.
    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    ASSERT_EQ(eina_list_count(loadedLanguages), eina_list_count(availableLanguages));

    i = 0;
    void* expected = 0;
    // Verify whether the loaded languages list is equal to the available languages list.
    EINA_LIST_FOREACH(loadedLanguages, listIterator, actual) {
        expected = eina_list_nth(availableLanguages, i++);
        EXPECT_STREQ(static_cast<const char*>(expected), static_cast<const char*>(actual));
    }

    // Delete the lists.
    EINA_LIST_FREE(availableLanguages, actual)
        eina_stringshare_del(static_cast<const char*>(actual));

    EINA_LIST_FREE(loadedLanguages, actual)
        eina_stringshare_del(static_cast<const char*>(actual));
}

/**
 * Here we test the following scenarios:
 *  - setting the default language,
 *  - if two arbitrarily selected dictionaries are set correctly.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages)
{
    // Set the default language.
    ewk_text_checker_spell_checking_languages_set(0);

    // Languages are being loaded on the idler, wait for them.
    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    ecore_main_loop_begin();

    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    // No dictionary is available/installed or the SPELLCHECK macro is disabled.
    if (!loadedLanguages)
        return;

    ASSERT_EQ(1, eina_list_count(loadedLanguages));

    // Delete the list.
    void* actual = 0;
    EINA_LIST_FREE(loadedLanguages, actual)
        eina_stringshare_del(static_cast<const char*>(actual));

    // Get the first and last language from installed dictionaries.
    Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
    unsigned numberOfAvailableLanguages = eina_list_count(availableLanguages);
    // We assume that user has installed at lest two dictionaries.
    if (numberOfAvailableLanguages < 2)
        return;

    const char* firstExpected = static_cast<const char*>(eina_list_nth(availableLanguages, 0));
    const char* lastExpected = static_cast<const char*>(eina_list_data_get(eina_list_last(availableLanguages)));

    // Case sensitivity of dictionaries doesn't affect on loading the dictionaries,
    // the Enchant library will 'normalize' them.
    WTF::StringBuilder languages;
    languages.append(String(firstExpected).upper());
    languages.append(',');
    languages.append(String(lastExpected).lower());

    // Set both languages (the first and the last) from the list.
    ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());

    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    ecore_main_loop_begin();

    loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    ASSERT_EQ(2, eina_list_count(loadedLanguages));

    EXPECT_STREQ(firstExpected, static_cast<const char*>(eina_list_nth(loadedLanguages, 0)));
    EXPECT_STREQ(lastExpected, static_cast<const char*>(eina_list_nth(loadedLanguages, 1)));

    // Delete the lists.
    EINA_LIST_FREE(availableLanguages, actual)
        eina_stringshare_del(static_cast<const char*>(actual));

    EINA_LIST_FREE(loadedLanguages, actual)
        eina_stringshare_del(static_cast<const char*>(actual));
}

/**
 * Test whether the client's callbacks aren't called (if not specified).
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker)
{
    resetCallbacksExecutionStats();
    ewk_text_checker_continuous_spell_checking_enabled_set(true);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    // If user doesn't specify callback functions responsible for spelling
    // the default WebKit implementation (based on the Enchant library) will be used.
    ASSERT_FALSE(callbacksExecutionStats.spellDocumentTag);
    ASSERT_FALSE(callbacksExecutionStats.spellDocumentTagClose);
    ASSERT_FALSE(callbacksExecutionStats.spellingCheck);

    // It doesn't make sense to verify others callbacks (onWordGuesses,
    // onWordLearn, onWordIgnore) as they need the context menu feature
    // which is not implemented for WK2-EFL.
}

/**
 * Test whether the client's callbacks (onSpellDocumentTag, onSpellDocumentTagClose) are called.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_unique_spell_document_tag)
{
    resetCallbacksExecutionStats();
    defaultView = webView();
    ewk_text_checker_continuous_spell_checking_enabled_set(true);

    ewk_text_checker_unique_spell_document_tag_get_cb_set(onSpellDocumentTag);
    ewk_text_checker_unique_spell_document_tag_close_cb_set(onSpellDocumentTagClose);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    // Check whether the callback was called.
    ASSERT_TRUE(callbacksExecutionStats.spellDocumentTag);
    // It's not possible to check whether onSpellDocumentTagClose was called here, because
    // it's invoked when WebPage is being destroyed.
    // It should be verified for example when view is freed.
}

/**
 * Test whether the client's callback (onSpellingCheck) is called when
 * the word to input field was put.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_string_spelling_check_cb_set)
{
    resetCallbacksExecutionStats();
    defaultView = webView();
    ewk_text_checker_continuous_spell_checking_enabled_set(true);

    ewk_text_checker_string_spelling_check_cb_set(onSpellingCheck);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    // Check whether the callback was called.
    ASSERT_TRUE(callbacksExecutionStats.spellingCheck);
}

/**
 * Test whether the client's callback (onWordGuesses) is called when
 * the context menu was shown on the misspelled word.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_guesses_get_cb_set)
{
    resetCallbacksExecutionStats();
    wasContextMenuShown = false;
    defaultView = webView();
    ewkViewClass()->context_menu_show = checkClientSuggestionsForWord;
    ewk_text_checker_word_guesses_get_cb_set(onWordGuesses);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    showContextMenu(FirstLine);
    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));

    // Check whether the callback is called.
    ASSERT_TRUE(callbacksExecutionStats.wordGuesses);

    ewk_text_checker_word_guesses_get_cb_set(0);
}

/**
 * Test whether the client's callback (onWordLearn) is called when
 * the context menu option "Learn spelling" was chosen. In the next step,
 * check whether the learned word is treated as spelled correctly while spell checking.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_learn_cb_set)
{
    resetCallbacksExecutionStats();
    knownWord = emptyString();
    defaultView = webView();
    ewk_text_checker_word_learn_cb_set(onWordLearn);
    ewkViewClass()->context_menu_show = selectLearnSpelling;

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    selectFirstWord(FirstLine);
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordLearn));

    // Open html again and check whether the learned word
    // is treated as spelled correctly while spell checking.
    resetCallbacksExecutionStats();
    ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    ASSERT_TRUE(callbacksExecutionStats.spellingCheck);

    ewk_text_checker_string_spelling_check_cb_set(0);
    ewk_text_checker_word_learn_cb_set(0);
}

/**
 * Test whether the client's callback (onWordIgnore) is called when
 * the context menu option "Ignore spelling" was chosen. In the next step,
 * check whether the ignored word is treated as spelled correctly while spell checking.
 */
TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_ignore_cb_set)
{
    resetCallbacksExecutionStats();
    knownWord = emptyString();
    defaultView = webView();
    ewk_text_checker_word_ignore_cb_set(onWordIgnore);
    ewkViewClass()->context_menu_show = selectIgnoreSpelling;

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    selectFirstWord(FirstLine);
    showContextMenu(FirstLine);

    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordIgnore));

    // Open html again and check whether the ignored word
    // is treated as spelled correctly while spell checking.
    resetCallbacksExecutionStats();
    ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);

    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));

    ASSERT_TRUE(callbacksExecutionStats.spellingCheck);

    ewk_text_checker_string_spelling_check_cb_set(0);
    ewk_text_checker_word_ignore_cb_set(0);
}


text:
import Backbone from "backbone"
import sinon from "sinon"
import articlesJSON from "./fixtures.coffee"
import fixtures from "desktop/test/helpers/fixtures.coffee"
import { cloneDeep, extend } from "lodash"
import { JSDOM } from "jsdom"

const jsdom = new JSDOM("<!doctype html>")
global.Node = jsdom.window.Node
global.DOMParser = jsdom.window.DOMParser

const rewire = require("rewire")("../routes")
const { articles, section, teamChannel } = rewire

describe("Articles routes", () => {
  let req
  let res
  let next
  let positronql

  beforeEach(() => {
    sinon.stub(Backbone, "sync")
    req = {
      params: {},
      query: {},
      user: {
        isAdmin: sinon.stub().returns(true),
      },
    }
    res = {
      render: sinon.stub(),
      locals: {
        sd: {},
      },
      redirect: sinon.stub(),
      backboneError: sinon.stub(),
    }
    next = sinon.stub()

    rewire.__set__(
      "topParselyArticles",
      sinon
        .stub()
        .yields([
          fixtures.parselyArticle,
          fixtures.parselyArticle,
          fixtures.parselyArticle,
        ])
    )

    positronql = sinon.stub().returns(
      Promise.resolve({
        articles: articlesJSON,
      })
    )
    rewire.__set__("positronql", positronql)
  })

  afterEach(() => {
    Backbone.sync.restore()
  })

  describe("#articles", () => {
    it("fetches published articles", () => {
      articles(req, res, next).then(() => {
        res.render.args[0][0].should.equal("articles")
        res.render.args[0][1].articles.length.should.equal(5)
      })
    })

    it("requests less than 50 articles with no offset by default", () => {
      articles(req, res, next).then(() => {
        positronql.args[0][0].query.should.containEql("limit: 50")
        positronql.args[0][0].query.should.containEql("offset: 0")
      })
    })
    describe("pagination", () => {
      it("accepts a page query parameter that offsets the results by limit * (page - 1)", () => {
        req.query.page = 3
        articles(req, res, next).then(() => {
          positronql.args[0][0].query.should.containEql("offset: 100")
          res.render.args[0][1].page.should.equal(3)
          res.locals.sd.PAGE.should.equal(3)
        })
      })

      it("gracefully handles invalid page input", () => {
        req.query.page = "foo"
        articles(req, res, next).then(() => {
          positronql.args[0][0].query.should.containEql("offset: 0")
          res.render.args[0][1].page.should.equal(1)
          res.locals.sd.PAGE.should.equal(1)
        })

        req.query.page = ""
        articles(req, res, next).then(() => {
          positronql.args[0][0].query.should.containEql("offset: 0")
          res.render.args[0][1].page.should.equal(1)
          res.locals.sd.PAGE.should.equal(1)
        })

        req.query.page = 0
        articles(req, res, next).then(() => {
          positronql.args[0][0].query.should.containEql("offset: 0")
          res.render.args[0][1].page.should.equal(1)
          res.locals.sd.PAGE.should.equal(1)
        })

        req.query.page = -1
        articles(req, res, next).then(() => {
          positronql.args[0][0].query.should.containEql("offset: 0")
          res.render.args[0][1].page.should.equal(1)
          res.locals.sd.PAGE.should.equal(1)
        })
      })
    })
  })

  describe("#section", () => {
    it("renders the section with articles", () => {
      const sectionObject = extend(cloneDeep(fixtures.section), {
        slug: "foo",
      })
      section(req, res, next)
      Backbone.sync.args[0][2].success(sectionObject)
      Backbone.sync.args[1][2].data.section_id.should.equal(sectionObject.id)
      Backbone.sync.args[1][2].success(fixtures.article)
      res.render.args[0][0].should.equal("section")
      res.render.args[0][1].section
        .get("title")
        .should.equal(sectionObject.title)
    })

    it("nexts for an error because it uses a root url", () => {
      section(req, res, next)
      Backbone.sync.args[0][2].error()
      next.called.should.be.ok()
    })
  })

  describe("#teamChannel", () => {
    it("renders the channel with its articles", () => {
      const channel = extend(cloneDeep(fixtures.channel), {
        slug: "foo",
        type: "team",
      })
      req.path = "foo"
      teamChannel(req, res, next)
      Backbone.sync.args[0][2].success(channel)
      Backbone.sync.args[1][2].data.ids.length.should.equal(4)
      Backbone.sync.args[1][2].success(fixtures.article)
      res.render.args[0][0].should.equal("team_channel")
      res.render.args[0][1].channel.get("name").should.equal(channel.name)
    })

    it("nexts if channel is not a team channel", () => {
      const channel = extend(cloneDeep(fixtures.channel), {
        slug: "foo",
        type: "editorial",
      })
      req.path = "/foo"
      teamChannel(req, res, next)
      Backbone.sync.args[0][2].success(channel)
      next.called.should.be.ok()
    })

    it("errors if there is an issue fetching a team channel", () => {
      const channel = extend(cloneDeep(fixtures.channel), {
        slug: "foo",
        type: "editorial",
      })
      req.path = "/foo"
      teamChannel(req, res, next)
      Backbone.sync.args[0][2].error(channel)
      res.backboneError.called.should.be.ok()
    })

    it("handles query params", () => {
      const channel = extend(cloneDeep(fixtures.channel), {
        slug: "foo",
        type: "team",
      })
      req.path = "/foo?utm=campaign"
      teamChannel(req, res, next)
      Backbone.sync.args[0][2].success(channel)
      Backbone.sync.args[1][2].success(fixtures.article)
      res.render.args[0][0].should.equal("team_channel")
      res.render.args[0][1].channel.get("name").should.equal(channel.name)
    })
  })
})

redpajama_set_name: RedPajamaGithub


text:
package org.eclipse.cft.server.ui.internal;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class CloudFoundryPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {

	public void init(IWorkbench workbench) {
		//
	}

	@Override
	protected Control createContents(Composite parent) {
		Composite mainArea = new Composite(parent, SWT.NONE);
		GridLayoutFactory.fillDefaults().numColumns(1).applyTo(mainArea);
		GridDataFactory.fillDefaults().grab(true, true).applyTo(mainArea);

		Label serviceLabel = new Label(mainArea, SWT.NONE);
		GridDataFactory.fillDefaults().grab(false, false).applyTo(serviceLabel);
		serviceLabel.setText(Messages.CloudFoundryPreferencePage_TEXT_SELECT_CF_FEATURE);

		return mainArea;
	}

}


text:
====
OWIN
====

`OWIN (Open Web Interface for .NET) <http://owin.org/>`_ is a simpler model for composing web-based applications without tying the application to the web server. To do this, a concept of "middleware" is used to create a pipeline through which requests travel.

Due to the differences in the way OWIN handles the application pipeline (detecting when a request starts/ends, etc.) integrating Autofac into an OWIN application is slightly different than the way it gets integrated into more "standard" ASP.NET apps. `You can read about OWIN and how it works on this overview. <http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana>`_

**The important thing to remember is that order of OWIN middleware registration matters.** Middleware gets processed in order of registration, like a chain, so you need to register foundational things (like Autofac middleware) first.

Quick Start
===========

To take advantage of Autofac in your OWIN pipeline:

* Reference the ``Autofac.Owin`` package from NuGet.
* Build your Autofac container.
* Register the Autofac middleware with OWIN and pass it the container.

.. sourcecode:: csharp

    public class Startup
    {
      public void Configuration(IAppBuilder app)
      {
        var builder = new ContainerBuilder();
        // Register dependencies, then...
        var container = builder.Build();

        // Register the Autofac middleware FIRST. This also adds
        // Autofac-injected middleware registered with the container.
        app.UseAutofacMiddleware(container);

        // ...then register your other middleware not registered
        // with Autofac.
      }
    }

Check out the individual :doc:`ASP.NET integration library <aspnet>` pages for specific details on different app types and how they handle OWIN support.

Dependency Injection in Middleware
==================================

Normally when you register OWIN middleware with your application, you use the extension methods that come with the middleware. For example :doc:`Web API <webapi>` has the ``app.UseWebApi(config);`` extension. Middleware registered in this fashion is statically defined and will not have dependencies injected.

For custom middleware, you can allow Autofac to inject dependencies into the middleware by registering it with your application container rather than registering it with a static extension.

.. sourcecode:: csharp

    var builder = new ContainerBuilder();
    builder.RegisterType<MyCustomMiddleware>();
    //...
    var container = builder.Build();

    // This will add the Autofac middleware as well as the middleware
    // registered in the container.
    app.UseAutofacMiddleware(container);

When you call ``app.UseAutofacMiddleware(container);`` the Autofac middleware itself will be added to the pipeline, after which any ``Microsoft.Owin.OwinMiddleware`` classes registered with the container will also be added to the pipeline.

Middleware registered in this way will be resolved from the request lifetime scope for each request passing through the OWIN pipeline.


text:
class DropToDoEvents < ActiveRecord::Migration
  def up
    drop_table :to_do_item_events
  end

  def down
    create_table :to_do_item_events do |t|
      t.references :to_do_item
      t.string     :event_name

      t.timestamps
    end
  end
end


text:
package featurescomparison.workingwithworkbook.fittoonepage.java;

import java.io.FileOutputStream;

import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ApacheFitSheetToOnePage {

 public static void main(String[]args) throws Exception
 {
	 String dataPath = "src/featurescomparison/workingwithworkbook/fittoonepage/data/";

     Workbook wb = new XSSFWorkbook();  //or new HSSFWorkbook();
     Sheet sheet = wb.createSheet("format sheet");
     PrintSetup ps = sheet.getPrintSetup();

     sheet.setAutobreaks(true);

     ps.setFitHeight((short) 1);
     ps.setFitWidth((short) 1);

     // Create various cells and rows for spreadsheet.

     FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheFitSheetToOnePage.xlsx");
     wb.write(fileOut);
     fileOut.close();
     System.out.println("Done.");
 }
}


text:
'use strict';

describe('Manage Misc Controller', function () {

    beforeEach(module('GVA.Manage'));

    var scope;

    var mockManageService;
    var mockNavigationService;

    var manageUpdatePollMiscPromise;

    beforeEach(inject(function ($rootScope, $q, $controller) {

        scope = $rootScope.$new();
        scope.poll = {};

        mockManageService = {
            poll: {},
            registerPollObserver: function () { },
            updatePollMisc: function () { }
        };
        manageUpdatePollMiscPromise = $q.defer();
        spyOn(mockManageService, 'updatePollMisc').and.callFake(function () { return manageUpdatePollMiscPromise.promise; });

        mockNavigationService = {
            navigateToManagePage: function () { }
        };
        spyOn(mockNavigationService, 'navigateToManagePage').and.callThrough();

        $controller('ManageMiscController', { $scope: scope, ManageService: mockManageService, RoutingService: mockNavigationService });
    }));

    describe('Update Poll', function () {

        it('Makes service call to Navigate To Manage Page when update service call succeeds', function () {
            manageUpdatePollMiscPromise.resolve();

            scope.updatePoll();

            scope.$apply();
            expect(mockNavigationService.navigateToManagePage).toHaveBeenCalled();
        });

        it('Does not make service call to Navigate To Manage Page if update service call fails', function () {
            manageUpdatePollMiscPromise.reject();

            scope.updatePoll();

            scope.$apply();
            expect(mockNavigationService.navigateToManagePage).not.toHaveBeenCalled();
        });

    });

});


text:
package com.asakusafw.testdriver.excel;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Calendar;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Rule;
import org.junit.Test;

import com.asakusafw.testdriver.core.DataModelDefinition;
import com.asakusafw.testdriver.core.DataModelReflection;
import com.asakusafw.testdriver.model.SimpleDataModelDefinition;

/**
 * Test for {@link ExcelSheetDataModelSource}.
 */
public class ExcelSheetDataModelSourceTest {

    /**
     * temporary resource manager.
     */
    @Rule
    public final TemporaryResource resources = new TemporaryResource();

    static final DataModelDefinition<Simple> SIMPLE = new SimpleDataModelDefinition<>(Simple.class);

    /**
     * simple.
     * @throws Exception if occur
     */
    @Test
    public void simple() throws Exception {
        ExcelSheetDataModelSource source = open("simple.xls");
        Simple simple = next(source);
        assertThat(simple.number, is(100));
        assertThat(simple.text, is("Hello, world!"));
        end(source);
    }

    /**
     * using xlsx.
     * @throws Exception if occur
     */
    @Test
    public void xssf() throws Exception {
        ExcelSheetDataModelSource source = open("simple.xlsx");
        Simple simple = next(source);
        assertThat(simple.number, is(100));
        assertThat(simple.text, is("Hello, world!"));
        end(source);
    }

    /**
     * multiple rows.
     * @throws Exception if occur
     */
    @Test
    public void multiple() throws Exception {
        ExcelSheetDataModelSource source = open("multiple.xls");
        Simple r1 = next(source);
        assertThat(r1.number, is(10));
        assertThat(r1.text, is("aaa"));

        Simple r2 = next(source);
        assertThat(r2.number, is(20));
        assertThat(r2.text, is("bbb"));

        Simple r3 = next(source);
        assertThat(r3.number, is(30));
        assertThat(r3.text, is("ccc"));

        end(source);
    }

    /**
     * contains blank cells.
     * @throws Exception if occur
     */
    @Test
    public void blank_cell() throws Exception {
        ExcelSheetDataModelSource source = open("blank_cell.xls");
        Simple r1 = next(source);
        assertThat(r1.number, is(10));
        assertThat(r1.text, is(nullValue()));

        Simple r2 = next(source);
        assertThat(r2.number, is(nullValue()));
        assertThat(r2.text, is("a"));

        end(source);
    }

    /**
     * stringified by '.
     * @throws Exception if occur
     */
    @Test
    public void stringify() throws Exception {
        ExcelSheetDataModelSource source = open("stringify.xls");
        Simple r1 = next(source);
        assertThat(r1.number, is(100));
        assertThat(r1.text, is("100"));

        Simple r2 = next(source);
        assertThat(r2.number, is(200));
        assertThat(r2.text, is("200"));

        end(source);
    }

    /**
     * empty string.
     * @throws Exception if occur
     */
    @Test
    public void empty_string() throws Exception {
        ExcelSheetDataModelSource source = open("empty_string.xls");
        Simple r1 = next(source);
        assertThat(r1.text, is(""));

        end(source);
    }

    /**
     * boolean values.
     * @throws Exception if occur
     */
    @Test
    public void boolean_values() throws Exception {
        ExcelSheetDataModelSource source = open("boolean.xls");

        Simple r1 = next(source);
        assertThat(r1.booleanValue, is(true));

        Simple r2 = next(source);
        assertThat(r2.booleanValue, is(false));

        Simple r3 = next(source);
        assertThat(r3.booleanValue, is(true));

        Simple r4 = next(source);
        assertThat(r4.booleanValue, is(false));

        Simple r5 = next(source);
        assertThat(r5.booleanValue, is(true));

        end(source);
    }

    /**
     * byte values.
     * @throws Exception if occur
     */
    @Test
    public void byte_values() throws Exception {
        ExcelSheetDataModelSource source = open("byte.xls");

        Simple r1 = next(source);
        assertThat(r1.byteValue, is(Byte.MIN_VALUE));

        Simple r2 = next(source);
        assertThat(r2.byteValue, is(Byte.MAX_VALUE));

        Simple r3 = next(source);
        assertThat(r3.byteValue, is((byte) -50));

        Simple r4 = next(source);
        assertThat(r4.byteValue, is((byte) +2));

        Simple r5 = next(source);
        assertThat(r5.byteValue, is((byte) 1));

        end(source);
    }

    /**
     * short values.
     * @throws Exception if occur
     */
    @Test
    public void short_values() throws Exception {
        ExcelSheetDataModelSource source = open("short.xls");

        Simple r1 = next(source);
        assertThat(r1.shortValue, is(Short.MIN_VALUE));

        Simple r2 = next(source);
        assertThat(r2.shortValue, is(Short.MAX_VALUE));

        Simple r3 = next(source);
        assertThat(r3.shortValue, is((short) -999));

        Simple r4 = next(source);
        assertThat(r4.shortValue, is((short) +10000));

        Simple r5 = next(source);
        assertThat(r5.shortValue, is((short) 1));

        end(source);
    }

    /**
     * int values.
     * @throws Exception if occur
     */
    @Test
    public void int_values() throws Exception {
        ExcelSheetDataModelSource source = open("int.xls");

        Simple r1 = next(source);
        assertThat(r1.number, is(Integer.MIN_VALUE));

        Simple r2 = next(source);
        assertThat(r2.number, is(Integer.MAX_VALUE));

        Simple r3 = next(source);
        assertThat(r3.number, is(-100000));

        Simple r4 = next(source);
        assertThat(r4.number, is(+200000));

        Simple r5 = next(source);
        assertThat(r5.number, is(1));

        end(source);
    }

    /**
     * long values.
     * @throws Exception if occur
     */
    @Test
    public void long_values() throws Exception {
        ExcelSheetDataModelSource source = open("long.xls");

        Simple r1 = next(source);
        assertThat(r1.longValue, is(-5000L));

        Simple r2 = next(source);
        assertThat(r2.longValue, is(+6000L));

        Simple r3 = next(source);
        assertThat(r3.longValue, is(Long.MIN_VALUE));

        Simple r4 = next(source);
        assertThat(r4.longValue, is(Long.MAX_VALUE));

        Simple r5 = next(source);
        assertThat(r5.longValue, is(1L));

        end(source);
    }

    /**
     * float values.
     * @throws Exception if occur
     */
    @Test
    public void float_values() throws Exception {
        ExcelSheetDataModelSource source = open("float.xls");

        Simple r1 = next(source);
        assertThat(r1.floatValue, is(-1.0f));

        Simple r2 = next(source);
        assertThat(r2.floatValue, is(+2.5f));

        Simple r3 = next(source);
        assertThat(r3.floatValue, is(-1.25f));

        Simple r4 = next(source);
        assertThat(r4.floatValue, is(+1000.0f));

        Simple r5 = next(source);
        assertThat(r5.floatValue, is(1f));

        end(source);
    }

    /**
     * double values.
     * @throws Exception if occur
     */
    @Test
    public void double_values() throws Exception {
        ExcelSheetDataModelSource source = open("double.xls");

        Simple r1 = next(source);
        assertThat(r1.doubleValue, is(-1.0d));

        Simple r2 = next(source);
        assertThat(r2.doubleValue, is(+2.5d));

        Simple r3 = next(source);
        assertThat(r3.doubleValue, is(-1.25d));

        Simple r4 = next(source);
        assertThat(r4.doubleValue, is(+1000.0d));

        Simple r5 = next(source);
        assertThat(r5.doubleValue, is(1d));

        end(source);
    }

    /**
     * big integer values.
     * @throws Exception if occur
     */
    @Test
    public void integer_values() throws Exception {
        ExcelSheetDataModelSource source = open("integer.xls");

        Simple r1 = next(source);
        assertThat(r1.bigIntegerValue, is(dec(-5000L).toBigInteger()));

        Simple r2 = next(source);
        assertThat(r2.bigIntegerValue, is(dec(+6000L).toBigInteger()));

        Simple r3 = next(source);
        assertThat(r3.bigIntegerValue, is(dec(Long.MIN_VALUE).subtract(BigDecimal.ONE).toBigInteger()));

        Simple r4 = next(source);
        assertThat(r4.bigIntegerValue, is(dec(Long.MAX_VALUE).add(BigDecimal.ONE).toBigInteger()));

        Simple r5 = next(source);
        assertThat(r5.bigIntegerValue, is(BigDecimal.ONE.toBigInteger()));

        end(source);
    }

    /**
     * big decimal values.
     * @throws Exception if occur
     */
    @Test
    public void decimal_values() throws Exception {
        ExcelSheetDataModelSource source = open("decimal.xls");

        Simple r1 = next(source);
        assertThat(r1.bigDecimalValue, is(dec(-5000L)));

        Simple r2 = next(source);
        assertThat(r2.bigDecimalValue, is(dec(+6000.5)));

        Simple r3 = next(source);
        assertThat(r3.bigDecimalValue, is(dec(+6000.5)));

        Simple r4 = next(source);
        assertThat(r4.bigDecimalValue, is(new BigDecimal("1.4142135623730950488016887242097")));

        Simple r5 = next(source);
        assertThat(r5.bigDecimalValue, is(new BigDecimal("1.1")));

        end(source);
    }

    /**
     * date values.
     * @throws Exception if occur
     */
    @Test
    public void date_values() throws Exception {
        ExcelSheetDataModelSource source = open("date.xls");

        Simple r1 = next(source);
        assertThat(r1.dateValue, is(date(2011, 6, 13)));

        Simple r2 = next(source);
        assertThat(r2.dateValue, is(date(2040, 1, 1)));

        Simple r3 = next(source);
        assertThat(r3.dateValue, is(date(2014, 6, 6)));

        end(source);
    }

    private Calendar date(int year, int month, int date) {
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(year, month - 1, date);
        return calendar;
    }

    /**
     * date values.
     * @throws Exception if occur
     */
    @Test
    public void datetime_values() throws Exception {
        ExcelSheetDataModelSource source = open("datetime.xls");

        Simple r1 = next(source);
        assertThat(r1.datetimeValue, is(datetime(2011, 6, 13, 23, 59, 59)));

        Simple r2 = next(source);
        assertThat(r2.datetimeValue, is(datetime(2040, 1, 1, 2, 3, 4)));

        Simple r3 = next(source);
        assertThat(r3.datetimeValue, is(datetime(2014, 6, 6, 7, 8, 9)));

        end(source);
    }

    private Calendar datetime(
            int year, int month, int date,
            int hour, int minute, int second) {
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(year, month - 1, date, hour, minute, second);
        return calendar;
    }

    private BigDecimal dec(long value) {
        return new BigDecimal(value);
    }

    private BigDecimal dec(double value) {
        return new BigDecimal(value);
    }

    /**
     * invalid boolean values.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void boolean_error() throws Exception {
        ExcelSheetDataModelSource source = open("boolean_error.xls");
        next(source);
    }

    /**
     * integer overflow.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void number_outofrange() throws Exception {
        ExcelSheetDataModelSource source = open("number_outofrange.xls");
        next(source);
    }

    /**
     * long integer overflow.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void long_outofrange() throws Exception {
        ExcelSheetDataModelSource source = open("long_outofrange.xls");
        next(source);
    }

    /**
     * invalid integer.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void number_error() throws Exception {
        ExcelSheetDataModelSource source = open("number_error.xls");
        next(source);
    }

    /**
     * invalid double.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void double_error() throws Exception {
        ExcelSheetDataModelSource source = open("double_error.xls");
        next(source);
    }

    /**
     * invalid big decimal.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void decimal_error() throws Exception {
        ExcelSheetDataModelSource source = open("decimal_error.xls");
        next(source);
    }

    /**
     * invalid string.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void string_error() throws Exception {
        ExcelSheetDataModelSource source = open("string_error.xls");
        next(source);
    }

    /**
     * invalid date.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void date_error() throws Exception {
        ExcelSheetDataModelSource source = open("date_error.xls");
        next(source);
    }

    /**
     * contains blank row.
     * @throws Exception if occur
     */
    @Test
    public void blank_row() throws Exception {
        ExcelSheetDataModelSource source = open("blank_row.xls");
        Simple r1 = next(source);
        assertThat(r1.number, is(100));
        assertThat(r1.text, is("vvv"));

        Simple r2 = next(source);
        assertThat(r2.number, is(200));
        assertThat(r2.text, is("^^^"));

        end(source);
    }

    /**
     * contains blank row but is decorated.
     * @throws Exception if occur
     */
    @Test
    public void decorated_blank_row() throws Exception {
        ExcelSheetDataModelSource source = open("decorated_blank_row.xls");
        Simple r1 = next(source);
        assertThat(r1.number, is(100));
        assertThat(r1.text, is("vvv"));

        Simple r2 = next(source);
        assertThat(r2.number, is(200));
        assertThat(r2.text, is("^^^"));

        end(source);
    }

    /**
     * blank sheet.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void blank_sheet() throws Exception {
        open("blank_sheet.xls");
    }

    /**
     * blank sheet but is decorated.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void decorated_blank_sheet() throws Exception {
        open("decorated_blank_sheet.xls");
    }

    /**
     * invalid sheet header.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void invalid_header() throws Exception {
        open("invalid_header.xls");
    }

    /**
     * blank sheet but is decorated.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void unknown_property() throws Exception {
        open("unknown_property.xls");
    }

    /**
     * formula.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void formula() throws Exception {
        ExcelSheetDataModelSource source = open("formula_error.xls");
        source.next();
    }

    /**
     * error cell.
     * @throws Exception if occur
     */
    @Test(expected = IOException.class)
    public void cell_error() throws Exception {
        ExcelSheetDataModelSource source = open("cell_error.xls");
        source.next();
    }

    private ExcelSheetDataModelSource open(String file) throws IOException {
        URL resource = getClass().getResource("data/" + file);
        assertThat(file, resource, not(nullValue()));
        URI uri;
        try {
            uri = resource.toURI();
        } catch (URISyntaxException e) {
            throw new AssertionError(e);
        }
        try (InputStream in = resource.openStream()) {
            Workbook book = resources.bless(Util.openWorkbookFor(file, in));
            Sheet sheet = book.getSheetAt(0);
            return new ExcelSheetDataModelSource(SIMPLE, uri, sheet);
        }
    }

    private Simple next(ExcelSheetDataModelSource source) throws IOException {
        DataModelReflection next = source.next();
        assertThat(next, is(not(nullValue())));
        return SIMPLE.toObject(next);
    }

    private void end(ExcelSheetDataModelSource source) throws IOException {
        DataModelReflection next = source.next();
        assertThat(String.valueOf(next), next, nullValue());
        source.close();
    }
}


text:
var weblas = require('weblas'),
	Tensor_unpacked	 = require('./tensor_unpacked')

var gl, float_support

var HOST
try {
	HOST = weblas.gpu.gl.__proto__.constructor
	gl = weblas.gpu.gl
	float_support = gl.hasFloat
} catch ( error ) { console.info( 'tensor_addin', error ) }

try {
	HOST = TCompute
	gl = window.tcompute
	float_support = gl.float_support
} catch ( error ) { console.info( 'tensor_addin', error ) }

// PACKED
/*
	original weblas tensor class update to cleanly coexist with unpacked type

	we can't update the constructor so we postinit some helper properties
	once we run one of the overriden or appended functions

	this is still cumbersome

*/

// constructor pseudo-patching
var Tensor = weblas.pipeline.Tensor

// Level out packed and unpacked types properties
Tensor.prototype.postinit = function() {
	if ( this.packed == null ) {
		this.gl = gl
		this.requires_padding = this.shape[1] % 4 != 0
		this.requires_encode = !float_support
		this.packed = true
	}
}
// Prototype overrides
Tensor.prototype.delete = function() {
	this.postinit()
	return Tensor_unpacked.prototype.delete.call( this )
}
Tensor.prototype.transfer = function( keep ) {
	this.postinit()
	return Tensor_unpacked.prototype.transfer.call( this, keep )
}
Tensor.prototype.transpose = function( keep ) {
	this.postinit()
	return Tensor_unpacked.prototype.transpose.call( this, keep )
}

// Crosschange
Tensor.prototype.pack = function() {
	this.postinit()
	return Tensor_unpacked.prototype.pack.call( this )
}
Tensor.prototype.unpack = function( slot ) {
	this.postinit()
	return Tensor_unpacked.prototype.unpack.call( this, slot )
}
Tensor.prototype.download = function( keep, unpacked ) {
	this.postinit()
	return Tensor_unpacked.prototype.download.call( this, keep, unpacked )
}
Tensor.prototype.duplicate = function() {
	this.postinit()
	return Tensor_unpacked.prototype.duplicate.call( this )
}


text:
package org.frc4931.robot.command.drive;

import org.frc4931.robot.OperatorInterface;
import org.frc4931.robot.Subsystems;

import edu.wpi.first.wpilibj.command.Command;

/**
 * Drives the robot in arcade mode using pitch for speed and yaw for turn.
 * @author zach
 *
 */
public class ModifiedDriveWithJoystick extends Command{

	public ModifiedDriveWithJoystick(){
		requires(Subsystems.driveTrain);
	}

	protected void initialize() {
	}

	protected void execute() {
		double rawDriveSpeed = OperatorInterface.joysticks[0].getPitch();
		double rawTurnSpeed = OperatorInterface.joysticks[0].getYaw()*-1;
		double scaledDriveSpeed = rawDriveSpeed*OperatorInterface.joysticks[0].getNormalThrottle();
		double scaledTurnSpeed = rawTurnSpeed*OperatorInterface.joysticks[0].getNormalThrottle();
		Subsystems.driveTrain.arcadeDrive(scaledDriveSpeed,scaledTurnSpeed);
	}

	protected boolean isFinished() {
		return true;
	}

	protected void end() {
	}

	protected void interrupted() {
		end();
	}

}


text:
package org.pentaho.di.connections.ui.dialog;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.BrowserFunction;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.pentaho.di.ui.core.dialog.ThinDialog;
import org.pentaho.di.ui.core.gui.GUIResource;
import org.pentaho.platform.settings.ServerPort;
import org.pentaho.platform.settings.ServerPortRegistry;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by bmorrise on 5/23/17.
 */
public class ConnectionDialog extends ThinDialog {

  private static final Image LOGO = GUIResource.getInstance().getImageLogoSmall();
  private static final String OSGI_SERVICE_PORT = "OSGI_SERVICE_PORT";
  private static final int OPTIONS = SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX;
  private static final String THIN_CLIENT_HOST = "THIN_CLIENT_HOST";
  private static final String THIN_CLIENT_PORT = "THIN_CLIENT_PORT";
  private static final String LOCALHOST = "localhost";

  public ConnectionDialog( Shell shell, int width, int height ) {
    super( shell, width, height );
  }

  public void open( String title ) {
    open( title, null );
  }

  public void open( String title, String connectionName ) {

    StringBuilder clientPath = new StringBuilder();
    clientPath.append( getClientPath() );
    if ( connectionName != null ) {
      clientPath.append( "#/summary" );
      clientPath.append( "?connection=" ).append( connectionName );
    } else {
      clientPath.append( "#/intro" );
    }
    super.createDialog( title, getRepoURL( clientPath.toString() ),
      OPTIONS, LOGO );
    super.dialog.setMinimumSize( 545, 458 );

    new BrowserFunction( browser, "close" ) {
      @Override public Object function( Object[] arguments ) {
        browser.dispose();
        dialog.close();
        dialog.dispose();
        return true;
      }
    };

    new BrowserFunction( browser, "setTitle" ) {
      @Override public Object function( Object[] arguments ) {
        dialog.setText( (String) arguments[ 0 ] );
        return true;
      }
    };

    new BrowserFunction( browser, "browse" ) {
      @Override public Object function( Object[] arguments ) {
        FileDialog dialog = new FileDialog( getParent().getShell(), SWT.OPEN );
        return dialog.open();
      }
    };

    while ( !dialog.isDisposed() ) {
      if ( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
  }

  private static String getClientPath() {
    Properties properties = new Properties();
    try {
      InputStream inputStream = ConnectionDialog.class.getClassLoader().getResourceAsStream( "project.properties" );
      properties.load( inputStream );
    } catch ( IOException e ) {
      e.printStackTrace();
    }
    return properties.getProperty( "CLIENT_PATH" );
  }

  private static Integer getOsgiServicePort() {
    // if no service port is specified try getting it from
    ServerPort osgiServicePort = ServerPortRegistry.getPort( OSGI_SERVICE_PORT );
    if ( osgiServicePort != null ) {
      return osgiServicePort.getAssignedPort();
    }
    return null;
  }

  private static String getRepoURL( String path ) {
    String host;
    Integer port;
    try {
      host = getKettleProperty( THIN_CLIENT_HOST );
      port = Integer.valueOf( getKettleProperty( THIN_CLIENT_PORT ) );
    } catch ( Exception e ) {
      host = LOCALHOST;
      port = getOsgiServicePort();
    }
    return "http://" + host + ":" + port + path;
  }

  private static String getKettleProperty( String propertyName ) {
    // loaded in system properties at startup
    return System.getProperty( propertyName );
  }
}


text:
/*\
title: $:/core/modules/widgets/edit-text.js
type: application/javascript
module-type: widget

Edit-text widget

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var editTextWidgetFactory = require("$:/core/modules/editor/factory.js").editTextWidgetFactory,
	FramedEngine = require("$:/core/modules/editor/engines/framed.js").FramedEngine,
	SimpleEngine = require("$:/core/modules/editor/engines/simple.js").SimpleEngine;

exports["edit-text"] = editTextWidgetFactory(FramedEngine,SimpleEngine);

})();


text:
(function() {

    var TransformRenderAdapter = function(factory, node) {
        XML3D.webgl.RenderAdapter.call(this, factory, node);
        this.isValid = true;
		this.needsUpdate = true;
    };

    XML3D.createClass(TransformRenderAdapter, XML3D.webgl.RenderAdapter);
    var p = TransformRenderAdapter.prototype;

	var IDENT_MAT = XML3D.math.mat4.identity(XML3D.math.mat4.create());

	p.init = function() {
	    // Create all matrices, no valid values yet
	    this.matrix = XML3D.math.mat4.create();
	    this.transform = {
	            translate              : XML3D.math.mat4.create(),
	            scale                  : XML3D.math.mat4.create(),
	            scaleOrientationInv    : XML3D.math.mat4.create(),
	            center                 : XML3D.math.mat4.create(),
                centerInverse          : XML3D.math.mat4.create()
	            //rotation               : XML3D.math.mat4.create()
	    };
        this.needsUpdate = true;
	};

	p.updateMatrix = function() {
        var n = this.node,
            transform = this.transform,
            transVec = n.translation._data,
            centerVec = n.center._data,
            s = n.scale._data,
            so = n.scaleOrientation.toMatrix()._data,
            rot = n.rotation.toMatrix()._data;

        XML3D.math.mat4.translate(transform.translate, IDENT_MAT, transVec);
        XML3D.math.mat4.translate(transform.center, IDENT_MAT, centerVec);
        XML3D.math.mat4.translate(transform.centerInverse, IDENT_MAT, XML3D.math.vec3.negate(centerVec, centerVec));
        XML3D.math.mat4.scale(transform.scale, IDENT_MAT, s);
        XML3D.math.mat4.invert(transform.scaleOrientationInv, so);

        // M = T * C
        XML3D.math.mat4.multiply(this.matrix, transform.translate, transform.center);
        // M = T * C * R
        XML3D.math.mat4.multiply(this.matrix, this.matrix, rot);
        // M = T * C * R * SO
        XML3D.math.mat4.multiply(this.matrix, this.matrix, so);
        // M = T * C * R * SO * S
        XML3D.math.mat4.multiply(this.matrix, this.matrix, transform.scale);
        // M = T * C * R * SO * S * -SO
        XML3D.math.mat4.multiply(this.matrix, this.matrix, transform.scaleOrientationInv);
        // M = T * C * R * SO * S * -SO * -C
        XML3D.math.mat4.multiply(this.matrix, this.matrix, transform.centerInverse);

        this.needsUpdate = false;
    };

	p.getMatrix = function() {
	    this.needsUpdate && this.updateMatrix();
	    return this.matrix;
	};

    p.notifyChanged = function(e) {
        if (e.type == 1) {
			this.needsUpdate = true;
        } else if (e.type == 2) {
            this.dispose();
        }
        this.notifyOppositeAdapters();
    };
    p.dispose = function() {
        this.isValid = false;
    };
    // Export to XML3D.webgl namespace
    XML3D.webgl.TransformRenderAdapter = TransformRenderAdapter;

    var DataRenderAdapter = function(factory, node) {
        XML3D.webgl.RenderAdapter.call(this, factory, node);
    };
    XML3D.createClass(DataRenderAdapter, XML3D.webgl.RenderAdapter);
    var p = DataRenderAdapter.prototype;

    p.init = function() {
        // Create all matrices, no valid values yet
        this.dataAdapter = XML3D.base.resourceManager.getAdapter(this.node, XML3D.data);
        this.matrixReady = {};
        this.matrices = {};
        this.requests = {};
    };

    p.updateMatrix = function(type) {

        createRequest(this, type);

        this.matrices[type] = XML3D.math.mat4.create();

        var dataResult =  this.requests[type].getResult();
        var transformData = (dataResult.getOutputData(type) && dataResult.getOutputData(type).getValue());
        if(!transformData){
            XML3D.math.mat4.identity(this.matrices[type]);
            return;
        }
        for(var i = 0; i < 16; ++i){
            this.matrices[type][i] = transformData[i];
        }
        this.matrixReady[type] = true;
    };

    p.getMatrix = function(type) {
        !this.matrixReady[type] && this.updateMatrix(type);
        return this.matrices[type];
    };

    p.dataChanged = function(request, changeType){
        for(var type in this.requests){
            if(this.requests[type] == request)
                delete this.matrixReady[type];
        }
        this.notifyOppositeAdapters();
    }

    function createRequest(adapter, key){
        if(!adapter.requests[key]){
            var that = adapter;
            adapter.requests[key] = adapter.dataAdapter.getComputeRequest([key],
                function(request, changeType) {
                    that.dataChanged(request, changeType);
                }
            );
        }
    }

    // Export to XML3D.webgl namespace
    XML3D.webgl.DataRenderAdapter = DataRenderAdapter;

}());


text: export { Umbrella20 as default } from "../../";


text:
import * as Twit from 'twit';

const t = new Twit( {
  consumer_key: '',
  consumer_secret: '',
  app_only_auth: true,
} );


text:
from rest_utils.permissions import Permission

class KeyProvided(Permission):
    def check(self, request):
        return request.events_provider is not None