Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapter test #3

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/lib/xdotool/adapter_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'minitest/autorun'
require_relative '../../test_helper'

module Xdotool
class AdapterTest < Minitest::Test
def setup
@position = { x: 1, y: 2 }
@adapter = Adapter.new
end

def test_left_click
mock_kernel = Minitest::Mock.new
mock_kernel.expect(:system, nil, ['xdotool mousemove 1 2 click 1'])
Kernel.stub :system, ->(a) { mock_kernel.system(a) } do
@adapter.left_click(@position)
end
mock_kernel.verify
end

def test_right_click
mock_kernel = Minitest::Mock.new
mock_kernel.expect(:system, nil, ['xdotool mousemove 1 2 click 3'])
Kernel.stub :system, ->(a) { mock_kernel.system(a) } do
@adapter.right_click(@position)
end
mock_kernel.verify
end
end
end
16 changes: 9 additions & 7 deletions test/lib/xdotool/position_parse_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
require 'minitest/autorun'
require_relative '../../test_helper'

class PositionParserTest < Minitest::Test
def setup
@position = 'x:761 y:1051 screen:0 window:20971523'
@expect_result = { x: 761, y: 1051 }
end
module Xdotool
class PositionParserTest < Minitest::Test
def setup
@position = 'x:761 y:1051 screen:0 window:20971523'
@expect_result = { x: 761, y: 1051 }
end

def test_version
assert_equal @expect_result, Xdotool::PositionParser.parse(@position)
def test_parser
assert_equal @expect_result, PositionParser.parse(@position)
end
end
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
require_relative '../lib/boaw'
require_relative '../lib/boaw/version'
require_relative '../lib/xdotool/position_parser'
require_relative '../lib/xdotool/adapter'