watchdoge 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7e1be951153dcc56e0c3a4932a1429e33e3c1569ece2b3a8e0f5b8ce876ce70
4
- data.tar.gz: 8b1aee985d16bb349ca81fab4836e5af4363e9ce6311554415013fe1298496d2
3
+ metadata.gz: '095e7358893894c7ce398fc669beafd1485e1fcb8429d47753c25f91774945a5'
4
+ data.tar.gz: a36c206bda55ded961f0e6440eb8415e28980361b1d8f867a997374f859b351c
5
5
  SHA512:
6
- metadata.gz: 025bc1db4d22c0fa6a190d5ce7d4f8cb7e81c8c2eb8191269bc4db3ea87d28e90902ebc470d12be9b7ad3ad9e5263a406ce1d279c6a4e7055c9bfe6d3e6b92ee
7
- data.tar.gz: 988085ef97efc7fcd176132d60286adfe520bb880d6c5cacd2e47b78a9fcfa596885dff012a38445a6bd5b89015cee70092e1b31050ca1797543d0ba565aebb7
6
+ metadata.gz: ad40e175dbdec71e2629091a1244a39cb9ea08d747c878c6afb6346c40a66a190d141689d182e6eea25f0f9725833fd8c75046d476edfcc4f08a0858bdee0a81
7
+ data.tar.gz: 976e99c48d5c34005c05d34732944b419f36dff3944e1191f54f17d29112dc9dd5a33f299143f4cc999a41ddd8e9312bfd7e787d433f2e28519fe499644521de
@@ -15,8 +15,15 @@ module WatchDoge
15
15
  sign_out_proc.call(@worker, resoruce)
16
16
  end
17
17
 
18
+ def with_viewport **kwargs
19
+ @view_port = kwargs
20
+ yield
21
+ @view_port = {}
22
+ end
23
+
18
24
  def compare path, **kwargs
19
25
  path = URI.join(WatchDoge.configuration.compare_host, path).to_s
26
+
20
27
  @reference_file_name =
21
28
  if kwargs[:with]
22
29
  kwargs[:with]
@@ -36,7 +43,15 @@ module WatchDoge
36
43
 
37
44
  @worker.goto path
38
45
 
39
- @compare_proc.call(@worker)
46
+ if kwargs[:wait]
47
+ @view_port.merge!({
48
+ wait: kwargs[:wait]
49
+ })
50
+ end
51
+
52
+ @worker.resize_by_document(@view_port) do
53
+ @compare_proc.call(@worker)
54
+ end
40
55
 
41
56
  @teardown_proc.call if @teardown_proc
42
57
  end
@@ -50,7 +50,8 @@ module WatchDoge
50
50
  @teardown_proc = nil
51
51
 
52
52
  @worker = WatchDoge::Worker.new @scenario_name
53
- @_authorized = false
53
+
54
+ @view_port = {}
54
55
  end
55
56
 
56
57
  def eval_scenario
@@ -1,3 +1,3 @@
1
1
  module WatchDoge
2
- Version = '0.0.10'
2
+ Version = '0.0.11'
3
3
  end
@@ -1,23 +1,5 @@
1
1
  module WatchDoge
2
- module PDFUtil
3
- def pdf_screenshot
4
- # no such thing as on_loaded for gecko pdf-viewer
5
- sleep 3
6
-
7
- firefox_pdf_viewer_id = 'viewer'
8
- firefox_scaler_id = 'scaleSelect'
9
- scale_factor = '0.75'
10
-
11
- #resize to 75%
12
- @core.select({id: firefox_scaler_id}).select(scale_factor)
13
-
14
- fullpage_screenshot({id: firefox_pdf_viewer_id})
15
- end
16
- end
17
-
18
2
  class Worker
19
- include WatchDoge::PDFUtil
20
-
21
3
  def initialize uuid, opt={}
22
4
  _before_initialize
23
5
 
@@ -47,8 +29,8 @@ module WatchDoge
47
29
  end
48
30
 
49
31
  def fullpage_screenshot **kwargs
50
- _resize_by_document(kwargs) do
51
- return @core.screenshot
32
+ resize_by_document(kwargs) do |resize|
33
+ return resize.screenshot
52
34
  end
53
35
  end
54
36
 
@@ -72,6 +54,29 @@ module WatchDoge
72
54
  @core
73
55
  end
74
56
 
57
+ def resize_by_document **kwargs
58
+ width, height = [@core.body.width, @core.body.height]
59
+
60
+ width += (kwargs.delete :width).to_i
61
+ height += (kwargs.delete :height).to_i
62
+ sleep_sec = (kwargs.delete :wait).to_i
63
+
64
+ unless kwargs.empty?
65
+ puts " -> wait rendering #{sleep_sec} sec"
66
+ sleep sleep_sec
67
+ target = @core.element(kwargs)
68
+ width += target.width
69
+ height += target.height
70
+ end
71
+
72
+ @core.window.resize_to [width, 5000].min, [height, 20000].min
73
+ sleep sleep_sec
74
+ @core.screenshot.save 'test.png'
75
+
76
+ yield(@core)
77
+ @core.window.resize_to @width, @height
78
+ end
79
+
75
80
  private
76
81
  # callbacks before/after init
77
82
  def _before_initialize
@@ -96,19 +101,6 @@ module WatchDoge
96
101
  @cookie_loaded = true
97
102
  end
98
103
 
99
- def _resize_by_document **kwargs
100
- target =
101
- if kwargs.empty?
102
- @core.body
103
- else
104
- @core.element(**kwargs)
105
- end
106
-
107
- @core.window.resize_to [target.width, 5000].min, [target.height, 20000].min
108
- yield
109
- @core.window.resize_to @width, @height
110
- end
111
-
112
104
  # try delegate all methods to @core
113
105
  def method_missing(method_name, *args)
114
106
  result = @core.__send__(method_name, *args)
data/watchdoge.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'watchdoge'
3
- s.version = '0.0.10'
3
+ s.version = '0.0.11'
4
4
  s.date = '2019-07-22'
5
5
  s.summary = "dogi"
6
6
  s.description = "A collection of web test tools"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchdoge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shen Lee