<commit_before>; Copyright © 2011 Sattvik Software & Technology Resources, Ltd. Co.
; All rights reserved.
;
; This program and the accompanying materials are made available under the
; terms of the Eclipse Public License v1.0 which accompanies this distribution,
; and is available at <http://www.eclipse.org/legal/epl-v10.html>.
;
; By using this software in any fashion, you are agreeing to be bound by the
; terms of this license.  You must not remove this notice, or any other, from
; this software.

(ns neko.dialog.alert-test
  "Tests for the neko.alert-dialog namespace."
  {:author "<NAME>"}
  (:gen-class :main false
              :extends android.test.AndroidTestCase
              :methods [[testNewBuilder [] void]
                        ]
              :exposes-methods {setUp superSetUp}
              )
  (:import neko.dialog.alert.FunctionalAlertDialogBuilder)
  (:use junit.assert
        neko.context
        neko.dialog.alert
        )
  )

(def context (atom nil))

(defn -setUp
  "Sets up the context atom"
  [this]
  (.superSetUp this)
  (reset! context (.getContext this)))

(defn -testNewBuilder
  "Tests the new-builder function."
  [this]
  ; without context
  (does-throw AssertionError (new-builder))
  ; non-context argument
  (does-throw AssertionError (new-builder "neko"))
  (is (instance? FunctionalAlertDialogBuilder (new-builder @context)))
  (with-context @context
    (is (instance? FunctionalAlertDialogBuilder (new-builder))))


  )<commit_msg>Add create test<commit_after>; Copyright © 2011 Sattvik Software & Technology Resources, Ltd. Co.
; All rights reserved.
;
; This program and the accompanying materials are made available under the
; terms of the Eclipse Public License v1.0 which accompanies this distribution,
; and is available at <http://www.eclipse.org/legal/epl-v10.html>.
;
; By using this software in any fashion, you are agreeing to be bound by the
; terms of this license.  You must not remove this notice, or any other, from
; this software.

(ns neko.dialog.alert-test
  "Tests for the neko.alert-dialog namespace."
  {:author "<NAME>"}
  (:gen-class :main false
              :extends android.test.AndroidTestCase
              :methods [[testNewBuilder [] void]
                        [testBasicCreate [] void]
                        ]
              :exposes-methods {setUp superSetUp}
              )
  (:import android.app.AlertDialog$Builder
           neko.dialog.alert.FunctionalAlertDialogBuilder)
  (:use junit.assert
        neko.context
        neko.find-view
        neko.dialog.alert
        )
  )

(def context (atom nil))

(defn -setUp
  "Sets up the context atom"
  [this]
  (.superSetUp this)
  (reset! context (.getContext this)))

(defn -testNewBuilder
  "Tests the new-builder function."
  [this]
  ; without context
  (does-throw AssertionError (new-builder))
  ; non-context argument
  (does-throw AssertionError (new-builder "neko"))
  (is (instance? FunctionalAlertDialogBuilder (new-builder @context)))
  (with-context @context
    (is (instance? FunctionalAlertDialogBuilder (new-builder)))))

(defn -testBasicCreate
  "Tests that the create function works with no other set-up."
  [this]
  (let [test-builder (fn [builder]
                       ; a simple test that just ensures a view exists
                       (let [dialog (create builder)]
                         (is-not-nil (find-view dialog :android/icon))))]
    ; test with android builder
    (test-builder (AlertDialog$Builder. @context))
    ; test with functional builder
    (test-builder (new-builder @context))))
{'fraction_non_alphanumeric': 0.10293706293706294, 'fraction_numerical': 0.0044755244755244755, 'mean_word_length': 2.8576051779935274, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '814381', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1000, 'n_words': 342}