• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 6557152774

18 Oct 2023 06:36AM UTC coverage: 52.519% (+39.8%) from 12.718%
6557152774

push

github

web-flow
Adding more tests, fixing bugs in the process (#48)

* Add config manager tests

* legacy config and mapping profile tests (should fix #42)

* remove comment, problem was caused by transfer across appdomain (or to/fro scripting environment)

* Test core functionality #48 + includes minor refactoring to be able to test + added docs

* Add interop tests + implement and test async test utility (refactors away from singletons)

* fix not all tests running in workflow

* config and interop tests

* Refactor and allow mocking global input hook class

* add capture action test

* Make Execute override optional for script only methods

* add dependency injection + refactor and try test gamepad service

* Refactor config singleton to using dependency injection

* add tests for scripting

* add tests for plugin set + fix plugin showing as loaded even if checksum match failed

* fix tests failing because it relied on config exist (I guess the test order was accidentally correct earlier, this means we should really fix cleanup so we catch this sooner)

* refactor docs code + fix wrong enum summary

* refactor docs builder and start testing it a bit

* fix cmd project structure

* ignore designer files in tests

* cleanup and refactor UI code + show latest version in help

* truncate listview action column

* allow user config to minimize app when pressing X (defaults to shut down app) resolves #45

696 of 1757 branches covered (0.0%)

Branch coverage included in aggregate %.

4597 of 4597 new or added lines in 138 files covered. (100.0%)

3619 of 6459 relevant lines covered (56.03%)

17089.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.08
/Core/Key2Joy.Core/Mapping/Actions/Graphics/GetPixelColorAction.cs
1
using System;
2
using System.Drawing;
3
using Key2Joy.Contracts.Mapping;
4
using Key2Joy.Contracts.Mapping.Actions;
5
using Key2Joy.Mapping.Actions.Scripting;
6

7
namespace Key2Joy.Mapping.Actions.Graphics;
8

9
[Action(
10
    Description = "Get Pixel Color",
11
    Visibility = MappingMenuVisibility.Never,
12
    NameFormat = "Get a Pixel Color"
13
)]
14
public class GetPixelColorAction : CoreAction
15
{
16
    private readonly Bitmap pixelCache = new(1, 1);
7✔
17

18
    public GetPixelColorAction(string name)
19
        : base(name)
7✔
20
    { }
7✔
21

22
    /// <markdown-doc>
23
    /// <parent-name>Graphics</parent-name>
24
    /// <path>Api/Graphics</path>
25
    /// </markdown-doc>
26
    /// <summary>
27
    /// Gets the color of a pixel at the given x and y position
28
    /// </summary>
29
    /// <markdown-example>
30
    /// Shows the color of the pixel at the mouse position
31
    /// <code language="lua">
32
    /// <![CDATA[
33
    /// local cursor = Cursor.GetPosition()
34
    /// local pixelColor = Graphics.GetPixelColor(cursor.X, cursor.Y)
35
    /// print(pixelColor.R) -- Red
36
    /// print(pixelColor.G) -- Green
37
    /// print(pixelColor.B) -- Blue
38
    /// print(pixelColor.A) -- Alpha (opacity, always 255)
39
    /// ]]>
40
    /// </code>
41
    /// </markdown-example>
42
    /// <returns>A color object containing Red, Green and Blue color information</returns>
43
    /// <param name="x">X position on screen</param>
44
    /// <param name="y">Y position on screen</param>
45
    /// <name>Graphics.GetPixelColor</name>
46
    [ExposesScriptingMethod("Graphics.GetPixelColor")]
47
    public Color ExecuteForScript(int x, int y)
48
    {
49
        Rectangle bounds = new(x, y, 1, 1);
×
50

51
        lock (BaseScriptAction.LockObject)
×
52
        {
53
            using var g = System.Drawing.Graphics.FromImage(this.pixelCache);
×
54
            g.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size);
×
55
        }
56

57
        return this.pixelCache.GetPixel(0, 0);
×
58
    }
59

60
    public override bool Equals(object obj)
61
    {
62
        if (obj is not GetPixelColorAction)
×
63
        {
64
            return false;
×
65
        }
66

67
        return true;
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc