sleipnir-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/Manifest.txt +7 -0
- data/README.txt +10 -4
- data/TODO.txt +21 -4
- data/bin/grepnir +91 -0
- data/examples/close_dup.rb +17 -0
- data/lib/sleipnir_api/cli/base.rb +77 -0
- data/lib/sleipnir_api/cli/grepnir.rb +188 -0
- data/lib/sleipnir_api/output.rb +2 -2
- data/lib/sleipnir_api/tab.rb +69 -9
- data/lib/sleipnir_api/util.rb +4 -0
- data/lib/sleipnir_api/version.rb +1 -1
- data/spec/dsl/behaviour_eval.rb +5 -0
- data/spec/matchers/exit_with.rb +35 -0
- data/spec/matchers/path_eql.rb +24 -26
- data/spec/sleipnir_api/cli/grepnir_spec.rb +341 -0
- data/spec/sleipnir_api/dialog_mock_spec.rb +1 -1
- data/spec/sleipnir_api/key_state_mock_spec.rb +1 -1
- data/spec/sleipnir_api/security_mock_spec.rb +1 -1
- data/spec/sleipnir_api/security_spec.rb +1 -1
- data/spec/sleipnir_api/sleipnir_spec.rb +20 -20
- data/spec/sleipnir_api/tab_mock_spec.rb +20 -2
- data/spec/sleipnir_api/tab_spec.rb +16 -3
- data/spec/spec_helper.rb +17 -0
- metadata +11 -4
data/lib/sleipnir_api/output.rb
CHANGED
@@ -52,14 +52,14 @@ module SleipnirAPI
|
|
52
52
|
api.OutputVisible=(show) #:nodoc:
|
53
53
|
end
|
54
54
|
|
55
|
-
#
|
55
|
+
# アウトプットバーを表示します。
|
56
56
|
#
|
57
57
|
# Sleipnir バージョンが 1.30 より低い場合例外を投げます。
|
58
58
|
def show
|
59
59
|
self.visible = true
|
60
60
|
end
|
61
61
|
|
62
|
-
#
|
62
|
+
# アウトプットバーを隠します。
|
63
63
|
#
|
64
64
|
# Sleipnir バージョンが 1.30 より低い場合例外を投げます。
|
65
65
|
def hide
|
data/lib/sleipnir_api/tab.rb
CHANGED
@@ -40,25 +40,81 @@ module SleipnirAPI
|
|
40
40
|
@id = id
|
41
41
|
end
|
42
42
|
|
43
|
+
# call-seq:
|
44
|
+
# window -> WIN32OLE object (DispHTMLWindow2)
|
45
|
+
# window{|window| ... }
|
46
|
+
#
|
43
47
|
# このタブの Window Object (DispHTMLWindow2 (WIN32OLE オブジェクト)) を取得します。
|
48
|
+
#
|
49
|
+
# * block を指定した場合、Window Object を引数に指定して block を実行し、block の結果を返します。
|
50
|
+
# * block を指定しない場合、Window Object を返します。
|
44
51
|
def window
|
45
|
-
self.api.GetWindowObject(self.id)
|
52
|
+
r = self.api.GetWindowObject(self.id)
|
53
|
+
if block_given?
|
54
|
+
yield r
|
55
|
+
else
|
56
|
+
r
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
60
|
+
# call-seq:
|
61
|
+
# document -> WIN32OLE object (DispHTMLDocument)
|
62
|
+
# document{|document| ... }
|
63
|
+
#
|
48
64
|
# このタブの HTML Document Object (DispHTMLDocument (WIN32OLE オブジェクト)) を取得します。
|
65
|
+
#
|
66
|
+
# * block を指定した場合、Document Object を引数に指定して block を実行し、block の結果を返します。
|
67
|
+
# * block を指定しない場合、Document Object を返します。
|
49
68
|
def document
|
50
|
-
self.api.GetDocumentObject(self.id)
|
69
|
+
r = self.api.GetDocumentObject(self.id)
|
70
|
+
if block_given?
|
71
|
+
yield r
|
72
|
+
else
|
73
|
+
r
|
74
|
+
end
|
51
75
|
end
|
52
76
|
|
77
|
+
# call-seq:
|
78
|
+
# browser -> WIN32OLE object (IWebBrowser2)
|
79
|
+
# browser{|browser| ... }
|
80
|
+
#
|
53
81
|
# このタブの WebBrowser Object (IWebBrowser2 (WIN32OLE オブジェクト)) を取得します。
|
82
|
+
#
|
83
|
+
# * block を指定した場合、WebBrowser Object を引数に指定して block を実行し、block の結果を返します。
|
84
|
+
# * block を指定しない場合、WebBrowser Object を返します。
|
54
85
|
def browser
|
55
|
-
self.api.GetWebBrowserObject(self.id)
|
86
|
+
r = self.api.GetWebBrowserObject(self.id)
|
87
|
+
if block_given?
|
88
|
+
yield r
|
89
|
+
else
|
90
|
+
r
|
91
|
+
end
|
56
92
|
end
|
57
93
|
alias web_browser browser
|
58
94
|
|
59
|
-
#
|
95
|
+
# call-seq:
|
96
|
+
# location -> WIN32OLE object (IHTMLLocation)
|
97
|
+
# location{|location| ... }
|
98
|
+
#
|
99
|
+
# このタブの Location Object (IHTMLLocation (WIN32OLE オブジェクト)) を取得します。
|
100
|
+
#
|
101
|
+
# * block を指定した場合、Location Object を引数に指定して block を実行し、block の結果を返します。
|
102
|
+
# * block を指定しない場合、Location Object を返します。
|
60
103
|
def location
|
61
|
-
document.location
|
104
|
+
r = document.location
|
105
|
+
if block_given?
|
106
|
+
yield r
|
107
|
+
else
|
108
|
+
r
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# このタブで選択しているテキストを取得します。
|
113
|
+
#
|
114
|
+
# 選択していない場合は空文字列を返します。
|
115
|
+
def selection_text
|
116
|
+
text = document.Selection.CreateRange.Text
|
117
|
+
text.gsub(/\r\n|[\r\n]/, "\n") if text
|
62
118
|
end
|
63
119
|
|
64
120
|
# このタブのセキュリティ設定を操作する SleipnirAPI::Security オブジェクトを取得します。
|
@@ -72,7 +128,11 @@ module SleipnirAPI
|
|
72
128
|
end
|
73
129
|
|
74
130
|
# このタブを閉じます。
|
75
|
-
|
131
|
+
#
|
132
|
+
# * +force+ が +true+ の場合、ナビゲートロックされたタブも close します。
|
133
|
+
# * +force+ が +false+ の場合、ナビゲートロックされたタブは close されません。
|
134
|
+
def close(force = false)
|
135
|
+
self.navigate_lock = false if force and navigate_lock?
|
76
136
|
self.api.Close(self.id)
|
77
137
|
end
|
78
138
|
|
@@ -90,8 +150,8 @@ module SleipnirAPI
|
|
90
150
|
end
|
91
151
|
|
92
152
|
# 指定されたキーワードにマッチする部分をハイライトします。
|
93
|
-
def hilight(
|
94
|
-
self.api.Hilight(self.id,
|
153
|
+
def hilight(*keywords)
|
154
|
+
self.api.Hilight(self.id, join_keyword(keywords))
|
95
155
|
end
|
96
156
|
|
97
157
|
# ドキュメントが読み込み中の場合 true を返します。
|
@@ -112,7 +172,7 @@ module SleipnirAPI
|
|
112
172
|
|
113
173
|
# このタブをアクティブにします。
|
114
174
|
def activate
|
115
|
-
self.sleipnir.active_index = index
|
175
|
+
self.sleipnir.active_index = index unless active?
|
116
176
|
end
|
117
177
|
|
118
178
|
|
data/lib/sleipnir_api/util.rb
CHANGED
data/lib/sleipnir_api/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Spec::Matchers
|
2
|
+
|
3
|
+
class ExitWith #:nodoc:
|
4
|
+
def initialize(status)
|
5
|
+
@expected_status = status
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(proc)
|
9
|
+
begin
|
10
|
+
proc.call
|
11
|
+
false
|
12
|
+
rescue SleipnirAPI::CLI::Exit => actual
|
13
|
+
@actual_status = actual.status
|
14
|
+
@actual_status == @expected_status
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_message
|
19
|
+
"expected exit with #{@expected_status}, got #{@actual_status.inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def negative_failure_message
|
23
|
+
"expected no exit with #{@expected_status}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def description
|
27
|
+
"exit #{@expected_status}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def exit_with(status)
|
32
|
+
::Spec::Matchers::ExitWith.new(status)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/matchers/path_eql.rb
CHANGED
@@ -7,35 +7,33 @@ class String
|
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
|
-
module Spec
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
return "expected #{@expected.inspect}, got #{@actual.inspect} (using path_normalize -> .eql?)", @expected, @actual
|
25
|
-
end
|
26
|
-
|
27
|
-
def negative_failure_message
|
28
|
-
return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using path_normalize -> .eql?)", @expected, @actual
|
29
|
-
end
|
30
|
-
|
31
|
-
def description
|
32
|
-
"path_eql #{@expected.inspect}"
|
33
|
-
end
|
10
|
+
module Spec::Matchers
|
11
|
+
|
12
|
+
class PathEql #:nodoc:
|
13
|
+
def initialize(expected)
|
14
|
+
@expected = expected.path_normalize
|
15
|
+
end
|
16
|
+
|
17
|
+
def matches?(actual)
|
18
|
+
@actual = actual.path_normalize
|
19
|
+
@actual.eql?(@expected)
|
20
|
+
end
|
21
|
+
|
22
|
+
def failure_message
|
23
|
+
return "expected #{@expected.inspect}, got #{@actual.inspect} (using path_normalize -> .eql?)", @expected, @actual
|
34
24
|
end
|
35
25
|
|
36
|
-
def
|
37
|
-
|
26
|
+
def negative_failure_message
|
27
|
+
return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using path_normalize -> .eql?)", @expected, @actual
|
38
28
|
end
|
39
29
|
|
30
|
+
def description
|
31
|
+
"path_eql #{@expected.inspect}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_eql(expected)
|
36
|
+
::Spec::Matchers::PathEql.new(expected)
|
40
37
|
end
|
38
|
+
|
41
39
|
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../../spec_helper.rb")
|
2
|
+
require "sleipnir_api/cli/grepnir"
|
3
|
+
|
4
|
+
describe SleipnirAPI::CLI::Grepnir do
|
5
|
+
include OptionParserSpecHelper
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@pnir = SleipnirAPI.connect
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@stdin = StringIO.new
|
16
|
+
@stdout = ""
|
17
|
+
@stderr = ""
|
18
|
+
@grepnir = SleipnirAPI::CLI::Grepnir.new(@stdin, StringIO.new(@stdout), StringIO.new(@stderr), false)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "default option are -T -S -A" do
|
22
|
+
ctx = @grepnir.prepare(args("baz"))
|
23
|
+
ctx.action.output.should be_true
|
24
|
+
ctx.action.activate.should be_true
|
25
|
+
ctx.action.search.should be_true
|
26
|
+
ctx.action.title_star.should be_true
|
27
|
+
ctx.action.lock.should be_nil
|
28
|
+
ctx.action.hilight.should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "#prepare should parse options" do
|
32
|
+
ctx = @grepnir.prepare(args("--no-search --no-activate --no-lock -H foo bar baz"))
|
33
|
+
ctx.action.output.should be_true
|
34
|
+
ctx.action.activate.should be_false
|
35
|
+
ctx.action.lock.should be_false
|
36
|
+
ctx.action.search.should be_false
|
37
|
+
ctx.action.hilight.should be_true
|
38
|
+
ctx.action.title_star.should be_true
|
39
|
+
ctx.keywords.should == %W(foo bar baz)
|
40
|
+
|
41
|
+
ctx = @grepnir.prepare(args("--search --activate --hilight --lock foo"))
|
42
|
+
ctx.action.output.should be_true
|
43
|
+
ctx.action.activate.should be_true
|
44
|
+
ctx.action.title_star.should be_true
|
45
|
+
ctx.action.lock.should be_true
|
46
|
+
ctx.action.search.should be_true
|
47
|
+
ctx.action.hilight.should be_true
|
48
|
+
ctx.keywords.should == %W(foo)
|
49
|
+
|
50
|
+
ctx = @grepnir.prepare(args("baz"))
|
51
|
+
ctx.action.output.should be_true
|
52
|
+
ctx.action.activate.should be_true
|
53
|
+
ctx.action.search.should be_true
|
54
|
+
ctx.action.hilight.should be_nil
|
55
|
+
ctx.action.lock.should be_nil
|
56
|
+
ctx.action.hilight.should be_nil
|
57
|
+
ctx.keywords.should == %W(baz)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "execute with empty keywords should output error message to stderr and exit with 2" do
|
61
|
+
@stdout.should be_empty
|
62
|
+
@stderr.should be_empty
|
63
|
+
|
64
|
+
r = @grepnir.execute(args(""))
|
65
|
+
r.should == 2
|
66
|
+
|
67
|
+
@stdout.should be_empty
|
68
|
+
@stderr.should match(/\Amissing PATTERN/)
|
69
|
+
@stderr.should match(/^Usage: grepnir/)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "execute with -h should output help to stdout and exit with 0" do
|
73
|
+
@stdout.should be_empty
|
74
|
+
@stderr.should be_empty
|
75
|
+
|
76
|
+
r = @grepnir.execute(args("-h"))
|
77
|
+
r.should == 0
|
78
|
+
|
79
|
+
@stdout.should match(/\AUsage: grepnir/)
|
80
|
+
@stderr.should be_empty
|
81
|
+
end
|
82
|
+
|
83
|
+
it "execute with -V should output version to stdout and exit with 0" do
|
84
|
+
@stdout.should be_empty
|
85
|
+
@stderr.should be_empty
|
86
|
+
|
87
|
+
r = @grepnir.execute(args("-V"))
|
88
|
+
r.should == 0
|
89
|
+
|
90
|
+
@stdout.should == "grepnir #{SleipnirAPI::VERSION::STRING}\n"
|
91
|
+
@stderr.should be_empty
|
92
|
+
end
|
93
|
+
|
94
|
+
it "activate 1st matched tab by default" do
|
95
|
+
t1 = @pnir.new_tab("about:foobar")
|
96
|
+
t2 = @pnir.new_tab("about:foobar")
|
97
|
+
begin
|
98
|
+
t2.activate
|
99
|
+
t1.should_not be_active
|
100
|
+
|
101
|
+
r = @grepnir.execute(args("foo"))
|
102
|
+
r.should == 0
|
103
|
+
t1.should be_active
|
104
|
+
t2.should_not be_active
|
105
|
+
ensure
|
106
|
+
t1.close(true)
|
107
|
+
t2.close(true)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "search keyword by default" do
|
112
|
+
t1 = @pnir.new_tab("about:foobar")
|
113
|
+
begin
|
114
|
+
t1.selection_text.should be_empty
|
115
|
+
|
116
|
+
r = @grepnir.execute(args("foo"))
|
117
|
+
r.should == 0
|
118
|
+
t1.selection_text.should == "foo"
|
119
|
+
ensure
|
120
|
+
t1.close(true)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it "output matched title/url by default" do
|
125
|
+
t1 = @pnir.new_tab("about:foobar")
|
126
|
+
t2 = @pnir.new_tab("about:foobar")
|
127
|
+
begin
|
128
|
+
@stdout.should be_empty
|
129
|
+
@stderr.should be_empty
|
130
|
+
|
131
|
+
t1.document.write("aqwsedrfgthyjuiklo")
|
132
|
+
t1.document.Title = "test test"
|
133
|
+
r = @grepnir.execute(args("aqwsedrfgthyjuiklo"))
|
134
|
+
r.should == 0
|
135
|
+
@stdout.should == "- * test test\n" +
|
136
|
+
" about:blank\n"
|
137
|
+
@stderr.should be_empty
|
138
|
+
ensure
|
139
|
+
t1.close(true)
|
140
|
+
t2.close(true)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it "execute with '-L' should navigate lock matched tab by default" do
|
145
|
+
t1 = @pnir.new_tab("about:foobar")
|
146
|
+
t2 = @pnir.new_tab("about:foobar")
|
147
|
+
t3 = @pnir.new_tab("about:baz")
|
148
|
+
begin
|
149
|
+
t1.should_not be_navigate_lock
|
150
|
+
t2.should_not be_navigate_lock
|
151
|
+
|
152
|
+
r = @grepnir.execute(args("-L foo"))
|
153
|
+
r.should == 0
|
154
|
+
t1.should be_navigate_lock
|
155
|
+
t2.should be_navigate_lock
|
156
|
+
t3.should_not be_navigate_lock
|
157
|
+
ensure
|
158
|
+
t1.close(true)
|
159
|
+
t2.close(true)
|
160
|
+
t3.close(true)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "execute with -v should perform invert match" do
|
165
|
+
t = @pnir.new_tab("about:foobar")
|
166
|
+
begin
|
167
|
+
t.should_not be_navigate_lock
|
168
|
+
|
169
|
+
r = @grepnir.execute(args("-L -v foobar"))
|
170
|
+
r.should == 1
|
171
|
+
t.should_not be_navigate_lock
|
172
|
+
|
173
|
+
r = @grepnir.execute(args("-L -v baz"))
|
174
|
+
r.should == 0
|
175
|
+
t.should be_navigate_lock
|
176
|
+
ensure
|
177
|
+
t.close(true)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "execute with '--include xxx' #target_tab? should return properly" do
|
182
|
+
t1 = @pnir.new_tab("about:foobar")
|
183
|
+
t2 = @pnir.new_tab("about:barbaz")
|
184
|
+
|
185
|
+
begin
|
186
|
+
ctx = @grepnir.prepare(args("--include foobar foo"))
|
187
|
+
@grepnir.target_tab?(ctx, t1).should be_true
|
188
|
+
@grepnir.target_tab?(ctx, t2).should be_false
|
189
|
+
ensure
|
190
|
+
t1.close(true)
|
191
|
+
t2.close(true)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
it "execute with '--include xxx' twice #target_tab? should return properly" do
|
196
|
+
t1 = @pnir.new_tab("about:foobar")
|
197
|
+
t2 = @pnir.new_tab("about:barbaz.com")
|
198
|
+
t3 = @pnir.new_tab("about:barbazDcom")
|
199
|
+
|
200
|
+
begin
|
201
|
+
ctx = @grepnir.prepare(args("--include foobar --include baz.com foo"))
|
202
|
+
@grepnir.target_tab?(ctx, t1).should be_true
|
203
|
+
@grepnir.target_tab?(ctx, t2).should be_true
|
204
|
+
@grepnir.target_tab?(ctx, t3).should be_false
|
205
|
+
ensure
|
206
|
+
t1.close(true)
|
207
|
+
t2.close(true)
|
208
|
+
t3.close(true)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
it "execute with '--exclude xxx' #target_tab? should return properly" do
|
213
|
+
t1 = @pnir.new_tab("about:foobar")
|
214
|
+
t2 = @pnir.new_tab("about:barbaz")
|
215
|
+
|
216
|
+
begin
|
217
|
+
ctx = @grepnir.prepare(args("--exclude foobar foo"))
|
218
|
+
@grepnir.target_tab?(ctx, t1).should be_false
|
219
|
+
@grepnir.target_tab?(ctx, t2).should be_true
|
220
|
+
ensure
|
221
|
+
t1.close(true)
|
222
|
+
t2.close(true)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
it "execute with '--exclude xxx' twice #target_tab? should return properly" do
|
227
|
+
t1 = @pnir.new_tab("about:foobar")
|
228
|
+
t2 = @pnir.new_tab("about:barbaz")
|
229
|
+
t3 = @pnir.new_tab("about:foofoo")
|
230
|
+
|
231
|
+
begin
|
232
|
+
ctx = @grepnir.prepare(args("--exclude foobar --exclude baz foo"))
|
233
|
+
@grepnir.target_tab?(ctx, t1).should be_false
|
234
|
+
@grepnir.target_tab?(ctx, t2).should be_false
|
235
|
+
@grepnir.target_tab?(ctx, t3).should be_true
|
236
|
+
ensure
|
237
|
+
t1.close(true)
|
238
|
+
t2.close(true)
|
239
|
+
t3.close(true)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
it "execute with '--only-locked-tab' #target_tab? should return properly" do
|
244
|
+
t1 = @pnir.new_tab("about:foobar")
|
245
|
+
t2 = @pnir.new_tab("about:barbaz")
|
246
|
+
|
247
|
+
begin
|
248
|
+
t1.navigate_lock = true
|
249
|
+
ctx = @grepnir.prepare(args("--only-locked-tab foo"))
|
250
|
+
@grepnir.target_tab?(ctx, t1).should be_true
|
251
|
+
@grepnir.target_tab?(ctx, t2).should be_false
|
252
|
+
ensure
|
253
|
+
t1.close(true)
|
254
|
+
t2.close(true)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
it "execute with '--inlclude --exclude --l' #target_tab? should return properly" do
|
259
|
+
t1 = @pnir.new_tab("about:foobar")
|
260
|
+
t2 = @pnir.new_tab("about:foobaz")
|
261
|
+
t3 = @pnir.new_tab("about:foofoo")
|
262
|
+
|
263
|
+
begin
|
264
|
+
t1.navigate_lock = true
|
265
|
+
ctx = @grepnir.prepare(args("-l --include foo --exclude baz kwd"))
|
266
|
+
@grepnir.target_tab?(ctx, t1).should be_true
|
267
|
+
@grepnir.target_tab?(ctx, t2).should be_false
|
268
|
+
@grepnir.target_tab?(ctx, t3).should be_false
|
269
|
+
ensure
|
270
|
+
t1.close(true)
|
271
|
+
t2.close(true)
|
272
|
+
t3.close(true)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
it "execute with no match control flags, #target_tab? should return true always" do
|
277
|
+
t1 = @pnir.new_tab("about:foobar")
|
278
|
+
t2 = @pnir.new_tab("about:foobaz")
|
279
|
+
t3 = @pnir.new_tab("about:foofoo")
|
280
|
+
|
281
|
+
begin
|
282
|
+
t1.navigate_lock = true
|
283
|
+
ctx = @grepnir.prepare(args(" kwd"))
|
284
|
+
@grepnir.target_tab?(ctx, t1).should be_true
|
285
|
+
@grepnir.target_tab?(ctx, t2).should be_true
|
286
|
+
@grepnir.target_tab?(ctx, t3).should be_true
|
287
|
+
ensure
|
288
|
+
t1.close(true)
|
289
|
+
t2.close(true)
|
290
|
+
t3.close(true)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
it "execute with '--include xxx --exclude xxx', #target_tab? should return false" do
|
295
|
+
t1 = @pnir.new_tab("about:foobar")
|
296
|
+
t2 = @pnir.new_tab("about:foobaz")
|
297
|
+
|
298
|
+
begin
|
299
|
+
t1.navigate_lock = true
|
300
|
+
ctx = @grepnir.prepare(args("--include foo --exclude foo kwd"))
|
301
|
+
@grepnir.target_tab?(ctx, t1).should be_false
|
302
|
+
@grepnir.target_tab?(ctx, t2).should be_false
|
303
|
+
ensure
|
304
|
+
t1.close(true)
|
305
|
+
t2.close(true)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
it "execute with '--include xxx' should search only xxx" do
|
310
|
+
t1 = @pnir.new_tab("about:foobar")
|
311
|
+
t2 = @pnir.new_tab("about:barbaz")
|
312
|
+
|
313
|
+
begin
|
314
|
+
r = @grepnir.execute(args("-L --include bar --exclude baz bar"))
|
315
|
+
r.should == 0
|
316
|
+
t1.should be_navigate_lock
|
317
|
+
t1.should be_active
|
318
|
+
t2.should_not be_navigate_lock
|
319
|
+
ensure
|
320
|
+
t1.close(true)
|
321
|
+
t2.close(true)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
it "execute with '--exclude xxx' should search without xxx" do
|
326
|
+
t1 = @pnir.new_tab("about:foobar")
|
327
|
+
t2 = @pnir.new_tab("about:barbaz")
|
328
|
+
|
329
|
+
begin
|
330
|
+
r = @grepnir.execute(args("-L --exclude about:foobar bar"))
|
331
|
+
r.should == 0
|
332
|
+
t1.should_not be_navigate_lock
|
333
|
+
t2.should be_active
|
334
|
+
t2.should be_navigate_lock
|
335
|
+
ensure
|
336
|
+
t1.close(true)
|
337
|
+
t2.close(true)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|