timr 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +1 -1
- data/.gitignore +2 -0
- data/Makefile +1 -1
- data/Makefile.common +3 -5
- data/bin/timr +14 -5
- data/lib/timr/stack.rb +15 -10
- data/lib/timr/task.rb +60 -11
- data/lib/timr/timr.rb +324 -117
- data/lib/timr/track.rb +75 -10
- data/lib/timr/version.rb +4 -4
- data/lib/timr/window.rb +29 -0
- data/lib/timr/window_help.rb +20 -18
- data/lib/timr/window_tasks.rb +6 -1
- data/lib/timr/window_timeline.rb +6 -1
- data/tests/tc_stack.rb +67 -45
- data/tests/tc_task.rb +55 -9
- data/tests/tc_track.rb +77 -40
- data/tests/tc_window.rb +309 -188
- metadata +2 -3
- data/Gemfile.lock +0 -29
data/tests/tc_track.rb
CHANGED
@@ -8,79 +8,116 @@ require 'timr'
|
|
8
8
|
|
9
9
|
class TestTrack < MiniTest::Test
|
10
10
|
def test_class_name
|
11
|
-
|
11
|
+
track1 = TheFox::Timr::Track.new
|
12
12
|
|
13
|
-
assert_equal('TheFox::Timr::Track',
|
13
|
+
assert_equal('TheFox::Timr::Track', track1.class.to_s)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_basic
|
17
|
-
|
18
|
-
assert_equal(
|
17
|
+
track1 = TheFox::Timr::Track.new
|
18
|
+
assert_equal(nil, track1.begin_time)
|
19
|
+
assert_equal(nil, track1.end_time)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_description
|
23
|
+
track1 = TheFox::Timr::Track.new
|
24
|
+
assert_equal(nil, track1.description)
|
25
|
+
|
26
|
+
track1.description = 'hello world1'
|
27
|
+
|
28
|
+
track2 = TheFox::Timr::Track.new
|
29
|
+
assert_equal(nil, track2.description)
|
30
|
+
|
31
|
+
track2.parent = track1
|
32
|
+
assert_equal(nil, track2.description)
|
33
|
+
|
34
|
+
track1.description = 'hello world2'
|
35
|
+
assert_equal(nil, track2.description)
|
19
36
|
end
|
20
37
|
|
21
38
|
def test_diff
|
22
|
-
|
23
|
-
assert_equal(0,
|
39
|
+
track1 = TheFox::Timr::Track.new
|
40
|
+
assert_equal(0, track1.diff)
|
24
41
|
|
25
|
-
|
26
|
-
|
27
|
-
assert_equal(59,
|
28
|
-
assert_equal(Fixnum,
|
42
|
+
track1.begin_time = Time.parse('1986-04-08 13:37:02')
|
43
|
+
track1.end_time = Time.parse('1986-04-08 13:38:01')
|
44
|
+
assert_equal(59, track1.diff)
|
45
|
+
assert_equal(Fixnum, track1.diff.class)
|
29
46
|
|
30
|
-
|
31
|
-
|
32
|
-
assert_equal(11979001,
|
33
|
-
assert_equal(Fixnum,
|
47
|
+
track1.begin_time = Time.parse('2015-01-16 23:00:00')
|
48
|
+
track1.end_time = Time.parse('2015-06-04 15:30:01')
|
49
|
+
assert_equal(11979001, track1.diff)
|
50
|
+
assert_equal(Fixnum, track1.diff.class)
|
34
51
|
end
|
35
52
|
|
36
53
|
def test_to_h
|
37
|
-
|
38
|
-
|
39
|
-
|
54
|
+
track1 = TheFox::Timr::Track.new
|
55
|
+
|
56
|
+
h = track1.to_h
|
57
|
+
assert_equal(false, h['id'].nil?)
|
40
58
|
assert_equal(nil, h['e'])
|
59
|
+
assert_equal(nil, h['d'])
|
60
|
+
assert_equal(nil, h['p'])
|
41
61
|
|
42
|
-
|
43
|
-
h =
|
62
|
+
track1.begin_time = Time.parse('1990-02-21 09:45')
|
63
|
+
h = track1.to_h
|
44
64
|
assert_equal('1990-02-21T08:45:00+0000', h['b'])
|
45
65
|
assert_equal(nil, h['e'])
|
46
66
|
|
47
|
-
|
48
|
-
|
49
|
-
|
67
|
+
track1.begin_time = Time.parse('1989-10-19 12:59')
|
68
|
+
track1.end_time = Time.parse('2012-12-14 20:45')
|
69
|
+
track1.description = 'hello world1'
|
70
|
+
h = track1.to_h
|
50
71
|
assert_equal('1989-10-19T11:59:00+0000', h['b'])
|
51
72
|
assert_equal('2012-12-14T19:45:00+0000', h['e'])
|
73
|
+
assert_equal('hello world1', h['d'])
|
52
74
|
|
53
|
-
|
54
|
-
|
55
|
-
|
75
|
+
track1.begin_time = Time.parse('2013-11-23 23:00')
|
76
|
+
track1.end_time = Time.parse('2013-11-24 09:00')
|
77
|
+
track1.description = 'hello world2'
|
78
|
+
h = track1.to_h
|
56
79
|
assert_equal('2013-11-23T22:00:00+0000', h['b'])
|
57
80
|
assert_equal('2013-11-24T08:00:00+0000', h['e'])
|
81
|
+
assert_equal('hello world2', h['d'])
|
58
82
|
end
|
59
83
|
|
60
84
|
def test_to_list_s
|
61
|
-
|
62
|
-
|
85
|
+
track1 = TheFox::Timr::Track.new
|
86
|
+
track1.begin_time = Time.parse('1990-08-29 12:34:56')
|
87
|
+
assert_equal('1990-08-29 12:34 - xx:xx ', track1.to_list_s)
|
88
|
+
|
89
|
+
task1 = TheFox::Timr::Task.new
|
90
|
+
task1.name = 'task1'
|
91
|
+
track1 = TheFox::Timr::Track.new
|
92
|
+
track1.begin_time = Time.parse('1990-08-29 12:34:56')
|
93
|
+
track1.task = task1
|
94
|
+
assert_equal('1990-08-29 12:34 - xx:xx task1', track1.to_list_s)
|
63
95
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
assert_equal('1990-08-29 12:34 - xx:xx task1', track.to_list_s)
|
96
|
+
track1.begin_time = Time.parse('1987-06-11 12:00:00')
|
97
|
+
track1.end_time = Time.parse('1987-06-12 23:00:00')
|
98
|
+
assert_equal('1987-06-11 12:00 - 23:00 1987-06-12 task1', track1.to_list_s)
|
68
99
|
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal('1987-06-11 12:00 - 23:00 1987-06-12 task1', track.to_list_s)
|
100
|
+
track1.description = 'hello world'
|
101
|
+
assert_equal('1987-06-11 12:00 - 23:00 1987-06-12 task1: hello world', track1.to_list_s)
|
72
102
|
end
|
73
103
|
|
74
104
|
def test_from_h
|
75
|
-
|
76
|
-
assert_equal(nil,
|
77
|
-
assert_equal(nil,
|
105
|
+
track1 = TheFox::Timr::Track.from_h(nil, {})
|
106
|
+
assert_equal(nil, track1.begin_time)
|
107
|
+
assert_equal(nil, track1.end_time)
|
78
108
|
|
79
|
-
|
109
|
+
track1 = TheFox::Timr::Track.from_h(nil, {
|
110
|
+
'id' => 'abc',
|
80
111
|
'b' => '1986-06-18 12:34:56+0000',
|
81
112
|
'e' => '2014-11-11 19:05:12+0000',
|
113
|
+
'd' => 'hello world',
|
114
|
+
'p' => '123',
|
82
115
|
})
|
83
|
-
assert_equal('
|
84
|
-
assert_equal('
|
116
|
+
assert_equal('abc', track1.id)
|
117
|
+
assert_equal('1986-06-18 14:34:56', track1.begin_time.strftime('%Y-%m-%d %H:%M:%S'))
|
118
|
+
assert_equal('2014-11-11 20:05:12', track1.end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
119
|
+
assert_equal('hello world', track1.description)
|
120
|
+
assert_equal(nil, track1.parent)
|
121
|
+
assert_equal('123', track1.parent_id)
|
85
122
|
end
|
86
123
|
end
|
data/tests/tc_window.rb
CHANGED
@@ -8,297 +8,418 @@ require 'timr'
|
|
8
8
|
|
9
9
|
class TestWindow < MiniTest::Test
|
10
10
|
def test_class_name
|
11
|
-
|
11
|
+
window1 = TheFox::Timr::Window.new
|
12
12
|
|
13
|
-
assert_equal('TheFox::Timr::Window',
|
13
|
+
assert_equal('TheFox::Timr::Window', window1.class.to_s)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_content_refresh
|
17
|
-
|
18
|
-
assert_equal(1,
|
17
|
+
window1 = TheFox::Timr::Window.new
|
18
|
+
assert_equal(1, window1.content_refreshes)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal(2,
|
20
|
+
window1.content_length = 10
|
21
|
+
window1.content_refresh
|
22
|
+
assert_equal(2, window1.content_refreshes)
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
assert_equal(2,
|
24
|
+
window1.content_length = 10
|
25
|
+
window1.content_refresh
|
26
|
+
assert_equal(2, window1.content_refreshes)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
assert_equal(3,
|
28
|
+
window1.content_length = 20
|
29
|
+
window1.content_refresh
|
30
|
+
assert_equal(3, window1.content_refreshes)
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
assert_equal(4,
|
32
|
+
window1.content_changed
|
33
|
+
window1.content_refresh
|
34
|
+
assert_equal(4, window1.content_refreshes)
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_page_refreshes
|
38
|
-
|
39
|
-
assert_equal(0,
|
38
|
+
window1 = TheFox::Timr::Window.new
|
39
|
+
assert_equal(0, window1.page_refreshes)
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal(1,
|
41
|
+
window1.content_changed
|
42
|
+
window1.content_refresh
|
43
|
+
window1.page
|
44
|
+
assert_equal(1, window1.page_refreshes)
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_page
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
page =
|
48
|
+
window1 = TheFox::Timr::TestWindow.new
|
49
|
+
window1.content_length = 3
|
50
|
+
window1.content_refresh
|
51
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
52
52
|
assert_equal(['LINE 001', 'LINE 002', 'LINE 003'], page)
|
53
|
-
assert_equal(3,
|
53
|
+
assert_equal(3, window1.page_length)
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
page =
|
55
|
+
window1.content_length = 4
|
56
|
+
window1.content_refresh
|
57
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
58
58
|
assert_equal(['LINE 001', 'LINE 002', 'LINE 003', 'LINE 004'], page)
|
59
|
-
assert_equal(4,
|
59
|
+
assert_equal(4, window1.page_length)
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_page_object
|
63
|
-
|
64
|
-
assert_equal(1,
|
63
|
+
window1 = TheFox::Timr::TestWindow.new
|
64
|
+
assert_equal(1, window1.cursor)
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
assert_equal('LINE 001',
|
66
|
+
window1.content_length = 3
|
67
|
+
window1.content_refresh
|
68
|
+
assert_equal('LINE 001', window1.page_object[0..7])
|
69
69
|
|
70
|
-
|
71
|
-
assert_equal('LINE 002',
|
70
|
+
window1.cursor_next_line
|
71
|
+
assert_equal('LINE 002', window1.page_object[0..7])
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_has_next_page
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
assert_equal(true,
|
75
|
+
window1 = TheFox::Timr::TestWindow.new
|
76
|
+
window1.content_length = 3
|
77
|
+
window1.content_refresh
|
78
|
+
assert_equal(true, window1.next_page?)
|
79
79
|
|
80
|
-
|
81
|
-
assert_equal(false,
|
80
|
+
window1.content_length = 30
|
81
|
+
assert_equal(false, window1.next_page?)
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
assert_equal(false,
|
83
|
+
window1.content_length = 30
|
84
|
+
window1.content_refresh
|
85
|
+
assert_equal(false, window1.next_page?)
|
86
86
|
|
87
|
-
|
88
|
-
assert_equal(false,
|
87
|
+
window1.content_length = 40
|
88
|
+
assert_equal(false, window1.next_page?)
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_has_previous_page
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
assert_equal(false,
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
assert_equal(false,
|
92
|
+
window1 = TheFox::Timr::TestWindow.new
|
93
|
+
window1.content_length = 3
|
94
|
+
window1.content_refresh
|
95
|
+
assert_equal(false, window1.previous_page?)
|
96
|
+
|
97
|
+
window1.content_length = 40
|
98
|
+
window1.content_refresh
|
99
|
+
assert_equal(false, window1.previous_page?)
|
100
100
|
end
|
101
101
|
|
102
102
|
def test_jmp_next_previous_page
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
window1 = TheFox::Timr::TestWindow.new
|
104
|
+
window1.content_length = 3
|
105
|
+
window1.content_refresh
|
106
106
|
|
107
|
-
page =
|
107
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
108
108
|
assert_equal((1..3).map{ |n| 'LINE %03d' % [n] }, page)
|
109
|
-
assert_equal(3,
|
110
|
-
assert_equal(0,
|
111
|
-
assert_equal(1,
|
109
|
+
assert_equal(3, window1.page_length)
|
110
|
+
assert_equal(0, window1.current_line)
|
111
|
+
assert_equal(1, window1.cursor)
|
112
112
|
|
113
|
-
|
114
|
-
assert_equal(3,
|
115
|
-
page =
|
113
|
+
window1.next_page
|
114
|
+
assert_equal(3, window1.current_line)
|
115
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
116
116
|
assert_equal((4..6).map{ |n| 'LINE %03d' % [n] }, page)
|
117
|
-
assert_equal(3,
|
118
|
-
assert_equal(1,
|
117
|
+
assert_equal(3, window1.page_length)
|
118
|
+
assert_equal(1, window1.cursor)
|
119
119
|
|
120
|
-
|
121
|
-
assert_equal(6,
|
122
|
-
page =
|
120
|
+
window1.next_page
|
121
|
+
assert_equal(6, window1.current_line)
|
122
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
123
123
|
assert_equal((7..9).map{ |n| 'LINE %03d' % [n] }, page)
|
124
|
-
assert_equal(3,
|
125
|
-
assert_equal(1,
|
124
|
+
assert_equal(3, window1.page_length)
|
125
|
+
assert_equal(1, window1.cursor)
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
page =
|
127
|
+
window1.content_length = 20
|
128
|
+
window1.content_refresh
|
129
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
130
130
|
assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
|
131
|
-
assert_equal(20,
|
132
|
-
assert_equal(6,
|
133
|
-
assert_equal(1,
|
131
|
+
assert_equal(20, window1.page_length)
|
132
|
+
assert_equal(6, window1.current_line)
|
133
|
+
assert_equal(1, window1.cursor)
|
134
134
|
|
135
|
-
|
136
|
-
assert_equal(7,
|
137
|
-
page =
|
135
|
+
window1.next_page(1)
|
136
|
+
assert_equal(7, window1.current_line)
|
137
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
138
138
|
assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
|
139
|
-
assert_equal(20,
|
140
|
-
assert_equal(1,
|
139
|
+
assert_equal(20, window1.page_length)
|
140
|
+
assert_equal(1, window1.cursor)
|
141
141
|
|
142
|
-
|
143
|
-
assert_equal(27,
|
144
|
-
page =
|
142
|
+
window1.next_page
|
143
|
+
assert_equal(27, window1.current_line)
|
144
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
145
145
|
assert_equal((28..30).map{ |n| 'LINE %03d' % [n] }, page)
|
146
|
-
assert_equal(3,
|
147
|
-
assert_equal(1,
|
146
|
+
assert_equal(3, window1.page_length)
|
147
|
+
assert_equal(1, window1.cursor)
|
148
148
|
|
149
|
-
|
150
|
-
assert_equal(7,
|
151
|
-
page =
|
149
|
+
window1.previous_page
|
150
|
+
assert_equal(7, window1.current_line)
|
151
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
152
152
|
assert_equal((8..27).map{ |n| 'LINE %03d' % [n] }, page)
|
153
|
-
assert_equal(20,
|
154
|
-
assert_equal(1,
|
153
|
+
assert_equal(20, window1.page_length)
|
154
|
+
assert_equal(1, window1.cursor)
|
155
155
|
|
156
|
-
|
157
|
-
assert_equal(6,
|
158
|
-
page =
|
156
|
+
window1.previous_page(1)
|
157
|
+
assert_equal(6, window1.current_line)
|
158
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
159
159
|
assert_equal((7..26).map{ |n| 'LINE %03d' % [n] }, page)
|
160
|
-
assert_equal(20,
|
161
|
-
assert_equal(1,
|
160
|
+
assert_equal(20, window1.page_length)
|
161
|
+
assert_equal(1, window1.cursor)
|
162
162
|
|
163
|
-
|
164
|
-
page =
|
163
|
+
window1.next_page
|
164
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
165
165
|
assert_equal((27..30).map{ |n| 'LINE %03d' % [n] }, page)
|
166
|
-
assert_equal(4,
|
167
|
-
assert_equal(1,
|
166
|
+
assert_equal(4, window1.page_length)
|
167
|
+
assert_equal(1, window1.cursor)
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
assert_equal(5,
|
172
|
-
assert_equal(1,
|
169
|
+
window1.previous_page(1)
|
170
|
+
window1.page
|
171
|
+
assert_equal(5, window1.page_length)
|
172
|
+
assert_equal(1, window1.cursor)
|
173
173
|
|
174
|
-
|
175
|
-
assert_equal(0,
|
176
|
-
assert_equal(1,
|
174
|
+
window1.first_page
|
175
|
+
assert_equal(0, window1.current_line)
|
176
|
+
assert_equal(1, window1.cursor)
|
177
177
|
|
178
|
-
|
179
|
-
assert_equal(0,
|
180
|
-
assert_equal(1,
|
178
|
+
window1.first_page
|
179
|
+
assert_equal(0, window1.current_line)
|
180
|
+
assert_equal(1, window1.cursor)
|
181
181
|
|
182
|
-
|
183
|
-
assert_equal(1,
|
184
|
-
page =
|
182
|
+
window1.next_page(1)
|
183
|
+
assert_equal(1, window1.current_line)
|
184
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
185
185
|
assert_equal((2..21).map{ |n| 'LINE %03d' % [n] }, page)
|
186
|
-
assert_equal(20,
|
187
|
-
assert_equal(1,
|
186
|
+
assert_equal(20, window1.page_length)
|
187
|
+
assert_equal(1, window1.cursor)
|
188
188
|
|
189
|
-
|
190
|
-
assert_equal(10,
|
191
|
-
page =
|
189
|
+
window1.last_page
|
190
|
+
assert_equal(10, window1.current_line)
|
191
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
192
192
|
assert_equal((11..30).map{ |n| 'LINE %03d' % [n] }, page)
|
193
|
-
assert_equal(20,
|
194
|
-
assert_equal(20,
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
assert_equal(0,
|
200
|
-
assert_equal(1,
|
201
|
-
page =
|
193
|
+
assert_equal(20, window1.page_length)
|
194
|
+
assert_equal(20, window1.cursor)
|
195
|
+
|
196
|
+
window1.first_page
|
197
|
+
window1.content_length = 6
|
198
|
+
window1.content_refresh
|
199
|
+
assert_equal(0, window1.current_line)
|
200
|
+
assert_equal(1, window1.cursor)
|
201
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
202
202
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
203
203
|
|
204
|
-
|
205
|
-
assert_equal(2,
|
206
|
-
page =
|
204
|
+
window1.cursor_next_line
|
205
|
+
assert_equal(2, window1.cursor)
|
206
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
207
207
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
208
208
|
|
209
|
-
|
210
|
-
assert_equal(3,
|
211
|
-
page =
|
209
|
+
window1.cursor_next_line
|
210
|
+
assert_equal(3, window1.cursor)
|
211
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
212
212
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
213
213
|
|
214
|
-
|
215
|
-
assert_equal(4,
|
216
|
-
page =
|
214
|
+
window1.cursor_next_line
|
215
|
+
assert_equal(4, window1.cursor)
|
216
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
217
217
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
218
218
|
|
219
|
-
|
220
|
-
assert_equal(4,
|
221
|
-
page =
|
219
|
+
window1.cursor_next_line
|
220
|
+
assert_equal(4, window1.cursor)
|
221
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
222
222
|
assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
|
223
223
|
|
224
224
|
(0..21).each do |n|
|
225
|
-
|
225
|
+
window1.cursor_next_line
|
226
226
|
end
|
227
|
-
assert_equal(4,
|
228
|
-
page =
|
227
|
+
assert_equal(4, window1.cursor)
|
228
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
229
229
|
assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
|
230
230
|
|
231
|
-
|
232
|
-
assert_equal(4,
|
233
|
-
page =
|
231
|
+
window1.cursor_next_line
|
232
|
+
assert_equal(4, window1.cursor)
|
233
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
234
234
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
235
235
|
|
236
|
-
|
237
|
-
assert_equal(5,
|
238
|
-
page =
|
236
|
+
window1.cursor_next_line
|
237
|
+
assert_equal(5, window1.cursor)
|
238
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
239
239
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
240
240
|
|
241
|
-
|
242
|
-
assert_equal(6,
|
243
|
-
page =
|
241
|
+
window1.cursor_next_line
|
242
|
+
assert_equal(6, window1.cursor)
|
243
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
244
244
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
245
245
|
|
246
|
-
|
247
|
-
assert_equal(6,
|
248
|
-
page =
|
246
|
+
window1.cursor_next_line
|
247
|
+
assert_equal(6, window1.cursor)
|
248
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
249
249
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
250
250
|
|
251
|
-
|
252
|
-
assert_equal(5,
|
253
|
-
page =
|
251
|
+
window1.cursor_previous_line
|
252
|
+
assert_equal(5, window1.cursor)
|
253
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
254
254
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
255
255
|
|
256
|
-
|
257
|
-
assert_equal(4,
|
258
|
-
page =
|
256
|
+
window1.cursor_previous_line
|
257
|
+
assert_equal(4, window1.cursor)
|
258
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
259
259
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
260
260
|
|
261
|
-
|
262
|
-
assert_equal(3,
|
263
|
-
page =
|
261
|
+
window1.cursor_previous_line
|
262
|
+
assert_equal(3, window1.cursor)
|
263
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
264
264
|
assert_equal((25..30).map{ |n| 'LINE %03d' % [n] }, page)
|
265
265
|
|
266
|
-
|
267
|
-
assert_equal(3,
|
268
|
-
page =
|
266
|
+
window1.cursor_previous_line
|
267
|
+
assert_equal(3, window1.cursor)
|
268
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
269
269
|
assert_equal((24..29).map{ |n| 'LINE %03d' % [n] }, page)
|
270
270
|
|
271
271
|
(0..21).each do |n|
|
272
|
-
|
272
|
+
window1.cursor_previous_line
|
273
273
|
end
|
274
|
-
assert_equal(3,
|
275
|
-
page =
|
274
|
+
assert_equal(3, window1.cursor)
|
275
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
276
276
|
assert_equal((2..7).map{ |n| 'LINE %03d' % [n] }, page)
|
277
277
|
|
278
|
-
|
279
|
-
assert_equal(3,
|
280
|
-
page =
|
278
|
+
window1.cursor_previous_line
|
279
|
+
assert_equal(3, window1.cursor)
|
280
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
281
281
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
282
282
|
|
283
|
-
|
284
|
-
assert_equal(2,
|
285
|
-
page =
|
283
|
+
window1.cursor_previous_line
|
284
|
+
assert_equal(2, window1.cursor)
|
285
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
286
286
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
287
287
|
|
288
|
-
|
289
|
-
assert_equal(1,
|
290
|
-
page =
|
288
|
+
window1.cursor_previous_line
|
289
|
+
assert_equal(1, window1.cursor)
|
290
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
291
291
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
292
292
|
|
293
|
-
|
294
|
-
assert_equal(1,
|
295
|
-
page =
|
293
|
+
window1.cursor_previous_line
|
294
|
+
assert_equal(1, window1.cursor)
|
295
|
+
page = window1.page.map{ |page_item| page_item[0..7] }
|
296
296
|
assert_equal((1..6).map{ |n| 'LINE %03d' % [n] }, page)
|
297
297
|
|
298
298
|
|
299
|
-
|
300
|
-
|
301
|
-
page =
|
299
|
+
window1.content = ['line 1', 'line 2', 'line 3']
|
300
|
+
window1.content_refresh
|
301
|
+
page = window1.page.map{ |page_item| page_item }
|
302
302
|
assert_equal((1..3).map{ |n| 'line %d' % [n] }, page)
|
303
303
|
end
|
304
|
+
|
305
|
+
def test_cursor_border_top_bottom
|
306
|
+
window1 = TheFox::Timr::TestWindow.new
|
307
|
+
window1.content_length = 7
|
308
|
+
window1.content_refresh
|
309
|
+
assert_equal(1, window1.cursor_border_top)
|
310
|
+
assert_equal(5, window1.cursor_border_bottom)
|
311
|
+
|
312
|
+
window1.cursor_next_line
|
313
|
+
assert_equal(1, window1.cursor_border_top)
|
314
|
+
assert_equal(5, window1.cursor_border_bottom)
|
315
|
+
|
316
|
+
window1.cursor_next_line
|
317
|
+
assert_equal(1, window1.cursor_border_top)
|
318
|
+
assert_equal(5, window1.cursor_border_bottom)
|
319
|
+
|
320
|
+
window1.cursor_next_line
|
321
|
+
assert_equal(1, window1.cursor_border_top)
|
322
|
+
assert_equal(5, window1.cursor_border_bottom)
|
323
|
+
|
324
|
+
window1.cursor_next_line
|
325
|
+
assert_equal(1, window1.cursor_border_top)
|
326
|
+
assert_equal(5, window1.cursor_border_bottom)
|
327
|
+
|
328
|
+
window1.cursor_next_line
|
329
|
+
assert_equal(3, window1.cursor_border_top)
|
330
|
+
assert_equal(5, window1.cursor_border_bottom)
|
331
|
+
|
332
|
+
21.times.each do
|
333
|
+
window1.cursor_next_line
|
334
|
+
assert_equal(3, window1.cursor_border_top)
|
335
|
+
assert_equal(5, window1.cursor_border_bottom)
|
336
|
+
end
|
337
|
+
|
338
|
+
2.times.each do
|
339
|
+
window1.cursor_next_line
|
340
|
+
assert_equal(3, window1.cursor_border_top)
|
341
|
+
assert_equal(7, window1.cursor_border_bottom)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_cursor_on_inner_range_multiple_pages
|
346
|
+
window1 = TheFox::Timr::TestWindow.new
|
347
|
+
window1.content_length = 7
|
348
|
+
window1.content_refresh
|
349
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
350
|
+
|
351
|
+
window1.cursor_next_line
|
352
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
353
|
+
|
354
|
+
window1.cursor_next_line
|
355
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
356
|
+
|
357
|
+
window1.cursor_next_line
|
358
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
359
|
+
|
360
|
+
window1.cursor_next_line
|
361
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
362
|
+
|
363
|
+
window1.cursor_next_line
|
364
|
+
assert_equal(false, window1.cursor_on_inner_range?)
|
365
|
+
|
366
|
+
window1.cursor_previous_line
|
367
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
368
|
+
window1.cursor_next_line
|
369
|
+
|
370
|
+
21.times.each do
|
371
|
+
window1.cursor_next_line
|
372
|
+
assert_equal(false, window1.cursor_on_inner_range?)
|
373
|
+
end
|
374
|
+
|
375
|
+
window1.cursor_next_line
|
376
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
377
|
+
|
378
|
+
window1.cursor_next_line
|
379
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
380
|
+
|
381
|
+
window1.cursor_next_line
|
382
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
383
|
+
|
384
|
+
window1.cursor_previous_line
|
385
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
386
|
+
|
387
|
+
window1.cursor_previous_line
|
388
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
389
|
+
|
390
|
+
window1.cursor_previous_line
|
391
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
392
|
+
|
393
|
+
window1.cursor_previous_line
|
394
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
395
|
+
|
396
|
+
window1.cursor_previous_line
|
397
|
+
assert_equal(false, window1.cursor_on_inner_range?)
|
398
|
+
|
399
|
+
21.times.each do
|
400
|
+
window1.cursor_previous_line
|
401
|
+
assert_equal(false, window1.cursor_on_inner_range?)
|
402
|
+
end
|
403
|
+
|
404
|
+
window1.cursor_previous_line
|
405
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
406
|
+
|
407
|
+
window1.cursor_previous_line
|
408
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
409
|
+
|
410
|
+
window1.cursor_previous_line
|
411
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_cursor_on_inner_range_one_page
|
415
|
+
window1 = TheFox::Timr::TestWindow.new
|
416
|
+
window1.content_length = 35
|
417
|
+
window1.content_refresh
|
418
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
419
|
+
|
420
|
+
29.times.each do
|
421
|
+
window1.cursor_next_line
|
422
|
+
assert_equal(true, window1.cursor_on_inner_range?)
|
423
|
+
end
|
424
|
+
end
|
304
425
|
end
|