3992c09a57ea8487df2300a663a4c05f59df36ea
[nit.git] / examples / mnit_simple / src / test_target_api.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2014 Frédéric Vachon <fredvac@gmail.com>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Test for the API level related annotations
18 module test_target_api is
19 android_api_min 10
20 android_api_max 19
21 end
22
23 import simple_android
24 #FIXME: Double quad to access lib/foo/goo/bar.nit is evil
25 import android::shared_preferences::shared_preferences_api11
26
27 redef class App
28 redef fun input( ie )
29 do
30 if ie isa PointerEvent and ie.depressed then
31 test_target_api
32 end
33 return super
34 end
35
36 fun test_target_api
37 do
38 var hash_set = new HashSet[JavaString]
39 hash_set.add "foo".to_java_string
40 hash_set.add "bar".to_java_string
41
42 shared_preferences.add_string_set("test", hash_set)
43
44 var hash_set2 = shared_preferences.string_set("test")
45
46 var tab = ["foo", "bar"]
47 var i = 0
48
49 for entry in hash_set2 do
50 assert entry == tab[i].to_java_string
51 i+=1
52 end
53
54 end
55 end