1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Frédéric Vachon <fredvac@gmail.com>
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Test for the intent module of App.nit framework
21 import android
::intent
::intent_api19
27 if ie
isa PointerEvent and ie
.depressed
then
35 intent
= new Intent(self)
36 intent
.action
= intent_action
.view
.to_s
37 intent
.data
= "content://contacts/people/"
39 intent
.launch_activity
42 intent
= new Intent(self)
43 var p1
= new Point(10, 20)
44 intent
["a_point"] = p1
45 var p2
= intent
["a_point"]
46 assert p1
.to_s
== p2
.to_s
48 intent
.action
= intent_action
.main
.to_s
49 assert intent
.action
== intent_action
.main
.to_s
51 intent
.add_flags intent_flag
.activity_brought_to_front
52 assert intent
.flags
== intent_flag
.activity_brought_to_front
54 var bool_array
= new Array[Bool]
55 for i
in [0..5] do bool_array
.add
( i
% 2 == 0 )
57 intent
.add_extra_array_of_bool
("bools", bool_array
)
58 var bool_array2
= intent
.extra_bool_array
("bools")
59 for i
in [0..5] do assert bool_array2
[i
] == (i
%2 ==0)
61 var string_array
= ["foo", "bar", "baz"]
62 intent
.add_extra_array_of_string
("strings", string_array
)
63 var string_array2
= intent
.extra_string_array
("strings")
64 for i
in [0..string_array2
.length
[ do assert string_array
[i
] == string_array2
[i
]
66 intent
.add_extra_array_list_of_string
("strings", string_array
)
67 string_array2
= intent
.extra_string_array_list
("strings")
68 for i
in [0..string_array2
.length
[ do assert string_array
[i
] == string_array2
[i
]
70 intent
.add_category intent_category
.home
.to_s
71 var categories
= intent
.categories
72 assert categories
.first
== intent_category
.home
.to_s
73 assert intent
.has_category
(intent_category
.home
.to_s
)