rautomation 0.9.4 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.rdoc +7 -0
- data/VERSION +1 -1
- data/ext/UiaDll/UiaDll/AutomatedTabControl.cpp +45 -0
- data/ext/UiaDll/UiaDll/AutomatedTabControl.h +41 -0
- data/ext/UiaDll/UiaDll/AutomationControl.h +7 -1
- data/ext/UiaDll/UiaDll/TabControlMethods.cpp +37 -0
- data/ext/UiaDll/UiaDll/UiaDll.cpp +0 -28
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +3 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +12 -0
- data/ext/WindowsForms/WindowsForms/AboutBox.Designer.cs +62 -5
- data/ext/WindowsForms/WindowsForms/AboutBox.resx +3 -0
- data/lib/rautomation/adapter/ms_uia.rb +1 -0
- data/lib/rautomation/adapter/ms_uia/functions.rb +1 -3
- data/lib/rautomation/adapter/ms_uia/tab_control.rb +46 -0
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +28 -2
- data/lib/rautomation/adapter/ms_uia/window.rb +5 -0
- data/spec/adapter/ms_uia/control_spec.rb +8 -0
- data/spec/adapter/ms_uia/tab_control_spec.rb +53 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d214593bdd0a96a896107ac65185546ba21fb97
|
4
|
+
data.tar.gz: 7067fcd4ff5bfdbdd0e3ea57528337de1b3a0003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d32f355823ab33e46aa0ee8400dd2771d3c027a5773e4b57271c5af4c8ca6de2178d1fe2a4227b423d5cfa257d5b6ada7177af120d29760826fbf24ca31bb45b
|
7
|
+
data.tar.gz: 5b84555b5f03746d8d395015a4b521dc676167045af85a4c55ed35d116a3c03212ff22086de3bc2239332e14084ee296eea548a5298de833c1d2112a8b57c7d6
|
data/Gemfile.lock
CHANGED
data/History.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#include "StdAfx.h"
|
2
|
+
#include "AutomatedTabControl.h"
|
3
|
+
|
4
|
+
AutomatedTabControl::AutomatedTabControl(const FindInformation& findInformation) : AutomationControl(findInformation)
|
5
|
+
{}
|
6
|
+
|
7
|
+
String^ AutomatedTabControl::Selection::get()
|
8
|
+
{
|
9
|
+
auto theSelection = AsSelectionPattern->Current.GetSelection()[0];
|
10
|
+
return theSelection->Current.Name;
|
11
|
+
}
|
12
|
+
|
13
|
+
void AutomatedTabControl::Selection::set(String^ value)
|
14
|
+
{
|
15
|
+
Select(_control->FindFirst(UIA::TreeScope::Subtree, GetNamedTabItemCondition(value)));
|
16
|
+
}
|
17
|
+
|
18
|
+
void AutomatedTabControl::SelectedIndex::set(int selectedIndex)
|
19
|
+
{
|
20
|
+
Select(TabItems[selectedIndex]);
|
21
|
+
}
|
22
|
+
|
23
|
+
int AutomatedTabControl::SelectedIndex::get()
|
24
|
+
{
|
25
|
+
int selectedIndex = 0;
|
26
|
+
for each(AutomationElement^ selectionItem in TabItems) {
|
27
|
+
auto selectionPattern = dynamic_cast<SelectionItemPattern^>(selectionItem->GetCurrentPattern(SelectionItemPattern::Pattern));
|
28
|
+
if( selectionPattern->Current.IsSelected ) {
|
29
|
+
return selectedIndex;
|
30
|
+
}
|
31
|
+
++selectedIndex;
|
32
|
+
}
|
33
|
+
return -1;
|
34
|
+
}
|
35
|
+
|
36
|
+
int AutomatedTabControl::GetTabItems(const char* options[])
|
37
|
+
{
|
38
|
+
auto tabItems = TabItems;
|
39
|
+
|
40
|
+
if( NULL != options ) {
|
41
|
+
StringHelper::CopyNames(tabItems, options);
|
42
|
+
}
|
43
|
+
|
44
|
+
return tabItems->Count;
|
45
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include "AutomationControl.h"
|
3
|
+
#include "StringHelper.h"
|
4
|
+
|
5
|
+
namespace UIA = System::Windows::Automation;
|
6
|
+
|
7
|
+
ref class AutomatedTabControl : AutomationControl
|
8
|
+
{
|
9
|
+
public:
|
10
|
+
AutomatedTabControl(const FindInformation& findInformation);
|
11
|
+
|
12
|
+
int GetTabItems(const char* options[]);
|
13
|
+
|
14
|
+
property String^ Selection {
|
15
|
+
String^ get();
|
16
|
+
void set(String^);
|
17
|
+
}
|
18
|
+
|
19
|
+
property int SelectedIndex {
|
20
|
+
int get();
|
21
|
+
void set(int);
|
22
|
+
}
|
23
|
+
|
24
|
+
private:
|
25
|
+
property AutomationElementCollection^ TabItems {
|
26
|
+
AutomationElementCollection^ get() { return _control->FindAll(UIA::TreeScope::Subtree, TabItemCondition); }
|
27
|
+
}
|
28
|
+
|
29
|
+
property Condition^ TabItemCondition {
|
30
|
+
Condition^ get() { return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, UIA::ControlType::TabItem); }
|
31
|
+
}
|
32
|
+
|
33
|
+
Condition^ GetNamedTabItemCondition(String^ name) {
|
34
|
+
return gcnew AndCondition(TabItemCondition, gcnew PropertyCondition(AutomationElement::NameProperty, name));
|
35
|
+
}
|
36
|
+
|
37
|
+
void Select(AutomationElement^ tabItem) {
|
38
|
+
dynamic_cast<SelectionItemPattern^>(tabItem->GetCurrentPattern(SelectionItemPattern::Pattern))->Select();
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
@@ -59,11 +59,17 @@ public:
|
|
59
59
|
protected:
|
60
60
|
AutomationElement^ _control;
|
61
61
|
|
62
|
-
|
62
|
+
protected:
|
63
63
|
property ValuePattern^ AsValuePattern {
|
64
64
|
ValuePattern^ get() {
|
65
65
|
return dynamic_cast<ValuePattern^>(_control->GetCurrentPattern(ValuePattern::Pattern));
|
66
66
|
}
|
67
67
|
}
|
68
|
+
|
69
|
+
property SelectionPattern^ AsSelectionPattern {
|
70
|
+
SelectionPattern^ get() {
|
71
|
+
return dynamic_cast<SelectionPattern^>(_control->GetCurrentPattern(SelectionPattern::Pattern));
|
72
|
+
}
|
73
|
+
}
|
68
74
|
};
|
69
75
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#include "stdafx.h"
|
2
|
+
#include "AutomatedTabControl.h"
|
3
|
+
|
4
|
+
extern "C" {
|
5
|
+
__declspec(dllexport) int TabControl_Items(const FindInformation& findInformation, const char* options[]) {
|
6
|
+
auto tabControl = gcnew AutomatedTabControl(findInformation);
|
7
|
+
return tabControl->GetTabItems(options);
|
8
|
+
}
|
9
|
+
|
10
|
+
__declspec(dllexport) void TabControl_Selection(const FindInformation& findInformation, char* selection, const int selectionLength) {
|
11
|
+
auto tabControl = gcnew AutomatedTabControl(findInformation);
|
12
|
+
StringHelper::CopyToUnmanagedString(tabControl->Selection, selection, selectionLength);
|
13
|
+
}
|
14
|
+
|
15
|
+
__declspec(dllexport) void TabControl_SelectByIndex(const FindInformation& findInformation, const int index, char* errorInfo, const int errorInfoLength) {
|
16
|
+
try {
|
17
|
+
auto tabControl = gcnew AutomatedTabControl(findInformation);
|
18
|
+
tabControl->SelectedIndex = index;
|
19
|
+
} catch(Exception^) {
|
20
|
+
_snprintf(errorInfo, errorInfoLength, "A tab with index %d was not found", index);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
__declspec(dllexport) int TabControl_SelectedIndex(const FindInformation& findInformation) {
|
25
|
+
auto tabControl = gcnew AutomatedTabControl(findInformation);
|
26
|
+
return tabControl->SelectedIndex;
|
27
|
+
}
|
28
|
+
|
29
|
+
__declspec(dllexport) void TabControl_SelectByValue(const FindInformation& findInformation, const char* value, char* errorInfo, const int errorInfoLength) {
|
30
|
+
try {
|
31
|
+
auto tabControl = gcnew AutomatedTabControl(findInformation);
|
32
|
+
tabControl->Selection = gcnew String(value);
|
33
|
+
} catch(Exception^) {
|
34
|
+
_snprintf(errorInfo, errorInfoLength, "A tab with the value %s was not found", value);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
@@ -148,34 +148,6 @@ extern "C" {
|
|
148
148
|
}
|
149
149
|
}
|
150
150
|
|
151
|
-
__declspec ( dllexport ) IUIAutomationElement *RA_FindChildById(IUIAutomationElement *pElement, char *automationId) {
|
152
|
-
IUIAutomationCondition *pCondition ;
|
153
|
-
VARIANT varProperty ;
|
154
|
-
|
155
|
-
VariantInit(&varProperty) ;
|
156
|
-
varProperty.vt = VT_BSTR ;
|
157
|
-
varProperty.bstrVal = _bstr_t(automationId) ;
|
158
|
-
|
159
|
-
HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
|
160
|
-
if (SUCCEEDED(hr)) {
|
161
|
-
IUIAutomationElement *pFound ;
|
162
|
-
|
163
|
-
hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
|
164
|
-
if (SUCCEEDED(hr)) {
|
165
|
-
if (pFound == NULL)
|
166
|
-
printf("RA_FindChildById: Element with automation id %s was not found\r\n", automationId) ;
|
167
|
-
|
168
|
-
return pFound ;
|
169
|
-
} else {
|
170
|
-
printf("RA_FindChildById: FindFirst for children looking for %s failed. hr = 0x%x\r\n", automationId, hr) ;
|
171
|
-
return NULL ;
|
172
|
-
}
|
173
|
-
} else {
|
174
|
-
printf("RA_FindChildById: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
175
|
-
return NULL ;
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
151
|
__declspec ( dllexport ) HWND RA_CurrentNativeWindowHandle(IUIAutomationElement *pElement) {
|
180
152
|
UIA_HWND uia_hwnd ;
|
181
153
|
|
@@ -80,6 +80,7 @@
|
|
80
80
|
</ItemGroup>
|
81
81
|
<ItemGroup>
|
82
82
|
<ClInclude Include="AutomatedSelectList.h" />
|
83
|
+
<ClInclude Include="AutomatedTabControl.h" />
|
83
84
|
<ClInclude Include="AutomatedTable.h" />
|
84
85
|
<ClInclude Include="AutomationClicker.h" />
|
85
86
|
<ClInclude Include="AutomationControl.h" />
|
@@ -99,6 +100,7 @@
|
|
99
100
|
<ItemGroup>
|
100
101
|
<ClCompile Include="AssemblyInfo.cpp" />
|
101
102
|
<ClCompile Include="AutomatedSelectList.cpp" />
|
103
|
+
<ClCompile Include="AutomatedTabControl.cpp" />
|
102
104
|
<ClCompile Include="AutomatedTable.cpp" />
|
103
105
|
<ClCompile Include="AutomationClicker.cpp" />
|
104
106
|
<ClCompile Include="AutomationControl.cpp" />
|
@@ -116,6 +118,7 @@
|
|
116
118
|
</ClCompile>
|
117
119
|
<ClCompile Include="StringHelper.cpp" />
|
118
120
|
<ClCompile Include="StringMethods.cpp" />
|
121
|
+
<ClCompile Include="TabControlMethods.cpp" />
|
119
122
|
<ClCompile Include="TableMethods.cpp" />
|
120
123
|
<ClCompile Include="AutomatedText.cpp" />
|
121
124
|
<ClCompile Include="TextMethods.cpp" />
|
@@ -55,6 +55,9 @@
|
|
55
55
|
<Filter Include="Header Files\Text">
|
56
56
|
<UniqueIdentifier>{3b3c2b83-e423-4619-991a-ffd7f324ae62}</UniqueIdentifier>
|
57
57
|
</Filter>
|
58
|
+
<Filter Include="Source Files\TabControl">
|
59
|
+
<UniqueIdentifier>{c8cf5521-2447-48f8-a48b-a4bf3909b00a}</UniqueIdentifier>
|
60
|
+
</Filter>
|
58
61
|
</ItemGroup>
|
59
62
|
<ItemGroup>
|
60
63
|
<ClInclude Include="UiaDll.h">
|
@@ -105,6 +108,9 @@
|
|
105
108
|
<ClInclude Include="AutomatedText.h">
|
106
109
|
<Filter>Header Files\Text</Filter>
|
107
110
|
</ClInclude>
|
111
|
+
<ClInclude Include="AutomatedTabControl.h">
|
112
|
+
<Filter>Header Files</Filter>
|
113
|
+
</ClInclude>
|
108
114
|
</ItemGroup>
|
109
115
|
<ItemGroup>
|
110
116
|
<ClCompile Include="UiaDll.cpp">
|
@@ -170,6 +176,12 @@
|
|
170
176
|
<ClCompile Include="AutomatedText.cpp">
|
171
177
|
<Filter>Source Files\Text</Filter>
|
172
178
|
</ClCompile>
|
179
|
+
<ClCompile Include="TabControlMethods.cpp">
|
180
|
+
<Filter>Source Files\TabControl</Filter>
|
181
|
+
</ClCompile>
|
182
|
+
<ClCompile Include="AutomatedTabControl.cpp">
|
183
|
+
<Filter>Source Files</Filter>
|
184
|
+
</ClCompile>
|
173
185
|
</ItemGroup>
|
174
186
|
<ItemGroup>
|
175
187
|
<None Include="ReadMe.txt" />
|
@@ -27,14 +27,22 @@
|
|
27
27
|
/// </summary>
|
28
28
|
private void InitializeComponent()
|
29
29
|
{
|
30
|
+
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox));
|
30
31
|
this.label1 = new System.Windows.Forms.Label();
|
31
32
|
this.button1 = new System.Windows.Forms.Button();
|
33
|
+
this.tabControl = new System.Windows.Forms.TabControl();
|
34
|
+
this.infoTab = new System.Windows.Forms.TabPage();
|
35
|
+
this.moreInfo = new System.Windows.Forms.TabPage();
|
36
|
+
this.textBox1 = new System.Windows.Forms.TextBox();
|
37
|
+
this.tabControl.SuspendLayout();
|
38
|
+
this.infoTab.SuspendLayout();
|
39
|
+
this.moreInfo.SuspendLayout();
|
32
40
|
this.SuspendLayout();
|
33
41
|
//
|
34
42
|
// label1
|
35
43
|
//
|
36
44
|
this.label1.AutoSize = true;
|
37
|
-
this.label1.Location = new System.Drawing.Point(
|
45
|
+
this.label1.Location = new System.Drawing.Point(6, 13);
|
38
46
|
this.label1.Name = "label1";
|
39
47
|
this.label1.Size = new System.Drawing.Size(303, 13);
|
40
48
|
this.label1.TabIndex = 0;
|
@@ -42,7 +50,7 @@
|
|
42
50
|
//
|
43
51
|
// button1
|
44
52
|
//
|
45
|
-
this.button1.Location = new System.Drawing.Point(
|
53
|
+
this.button1.Location = new System.Drawing.Point(12, 277);
|
46
54
|
this.button1.Name = "button1";
|
47
55
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
48
56
|
this.button1.TabIndex = 1;
|
@@ -50,13 +58,54 @@
|
|
50
58
|
this.button1.UseVisualStyleBackColor = true;
|
51
59
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
52
60
|
//
|
61
|
+
// tabControl
|
62
|
+
//
|
63
|
+
this.tabControl.Controls.Add(this.infoTab);
|
64
|
+
this.tabControl.Controls.Add(this.moreInfo);
|
65
|
+
this.tabControl.Location = new System.Drawing.Point(12, 12);
|
66
|
+
this.tabControl.Name = "tabControl";
|
67
|
+
this.tabControl.SelectedIndex = 0;
|
68
|
+
this.tabControl.Size = new System.Drawing.Size(551, 253);
|
69
|
+
this.tabControl.TabIndex = 2;
|
70
|
+
//
|
71
|
+
// infoTab
|
72
|
+
//
|
73
|
+
this.infoTab.Controls.Add(this.label1);
|
74
|
+
this.infoTab.Location = new System.Drawing.Point(4, 22);
|
75
|
+
this.infoTab.Name = "infoTab";
|
76
|
+
this.infoTab.Padding = new System.Windows.Forms.Padding(3);
|
77
|
+
this.infoTab.Size = new System.Drawing.Size(543, 227);
|
78
|
+
this.infoTab.TabIndex = 0;
|
79
|
+
this.infoTab.Text = "Info";
|
80
|
+
this.infoTab.UseVisualStyleBackColor = true;
|
81
|
+
//
|
82
|
+
// moreInfo
|
83
|
+
//
|
84
|
+
this.moreInfo.Controls.Add(this.textBox1);
|
85
|
+
this.moreInfo.Location = new System.Drawing.Point(4, 22);
|
86
|
+
this.moreInfo.Name = "moreInfo";
|
87
|
+
this.moreInfo.Padding = new System.Windows.Forms.Padding(3);
|
88
|
+
this.moreInfo.Size = new System.Drawing.Size(543, 227);
|
89
|
+
this.moreInfo.TabIndex = 1;
|
90
|
+
this.moreInfo.Text = "More Info";
|
91
|
+
this.moreInfo.UseVisualStyleBackColor = true;
|
92
|
+
//
|
93
|
+
// textBox1
|
94
|
+
//
|
95
|
+
this.textBox1.Location = new System.Drawing.Point(6, 3);
|
96
|
+
this.textBox1.Multiline = true;
|
97
|
+
this.textBox1.Name = "textBox1";
|
98
|
+
this.textBox1.Size = new System.Drawing.Size(531, 218);
|
99
|
+
this.textBox1.TabIndex = 0;
|
100
|
+
this.textBox1.Text = resources.GetString("textBox1.Text");
|
101
|
+
//
|
53
102
|
// AboutBox
|
54
103
|
//
|
55
104
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
56
105
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
57
|
-
this.ClientSize = new System.Drawing.Size(
|
106
|
+
this.ClientSize = new System.Drawing.Size(575, 312);
|
58
107
|
this.Controls.Add(this.button1);
|
59
|
-
this.Controls.Add(this.
|
108
|
+
this.Controls.Add(this.tabControl);
|
60
109
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
61
110
|
this.MaximizeBox = false;
|
62
111
|
this.MinimizeBox = false;
|
@@ -66,8 +115,12 @@
|
|
66
115
|
this.ShowInTaskbar = false;
|
67
116
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
68
117
|
this.Text = "About";
|
118
|
+
this.tabControl.ResumeLayout(false);
|
119
|
+
this.infoTab.ResumeLayout(false);
|
120
|
+
this.infoTab.PerformLayout();
|
121
|
+
this.moreInfo.ResumeLayout(false);
|
122
|
+
this.moreInfo.PerformLayout();
|
69
123
|
this.ResumeLayout(false);
|
70
|
-
this.PerformLayout();
|
71
124
|
|
72
125
|
}
|
73
126
|
|
@@ -75,6 +128,10 @@
|
|
75
128
|
|
76
129
|
private System.Windows.Forms.Label label1;
|
77
130
|
private System.Windows.Forms.Button button1;
|
131
|
+
private System.Windows.Forms.TabControl tabControl;
|
132
|
+
private System.Windows.Forms.TabPage infoTab;
|
133
|
+
private System.Windows.Forms.TabPage moreInfo;
|
134
|
+
private System.Windows.Forms.TextBox textBox1;
|
78
135
|
|
79
136
|
}
|
80
137
|
}
|
@@ -117,4 +117,7 @@
|
|
117
117
|
<resheader name="writer">
|
118
118
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
119
119
|
</resheader>
|
120
|
+
<data name="textBox1.Text" xml:space="preserve">
|
121
|
+
<value>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean et urna tellus. Ut tincidunt ligula quam, sed mattis eros suscipit id. In volutpat, enim at scelerisque elementum, dui tellus cursus metus, et dignissim mi nulla eget nisl. Duis ipsum orci, placerat nec libero a, vulputate bibendum tellus. Sed accumsan est ipsum, a tincidunt nunc dictum eget. Proin mattis iaculis nisl. Suspendisse ac velit ac augue feugiat mollis vitae in velit. Donec rutrum nunc hendrerit, aliquet lorem quis, cursus enim. Nam vel aliquet dolor, fermentum molestie risus. Curabitur vitae nulla eget est tempus elementum. Nunc venenatis posuere lorem, nec consectetur libero semper in.</value>
|
122
|
+
</data>
|
120
123
|
</root>
|
@@ -20,6 +20,7 @@ require File.dirname(__FILE__) + "/ms_uia/radio"
|
|
20
20
|
require File.dirname(__FILE__) + "/ms_uia/text_field"
|
21
21
|
require File.dirname(__FILE__) + "/ms_uia/select_list"
|
22
22
|
require File.dirname(__FILE__) + "/ms_uia/table"
|
23
|
+
require File.dirname(__FILE__) + "/ms_uia/tab_control"
|
23
24
|
require File.dirname(__FILE__) + "/ms_uia/label"
|
24
25
|
require File.dirname(__FILE__) + "/ms_uia/list_box"
|
25
26
|
require File.dirname(__FILE__) + "/ms_uia/list_item"
|
@@ -168,9 +168,7 @@ module RAutomation
|
|
168
168
|
def control_hwnd(window_hwnd, locators)
|
169
169
|
case
|
170
170
|
when locators[:id]
|
171
|
-
|
172
|
-
uia_control = UiaDll::find_child_by_id(uia_window, locators[:id].to_s)
|
173
|
-
hwnd = UiaDll::current_native_window_handle(uia_control) # return HWND of UIA element
|
171
|
+
hwnd = UiaDll.cached_hwnd(UiaDll::SearchCriteria.from_locator(window_hwnd, locators))
|
174
172
|
raise UnknownElementException, "#{locators[:id]} does not exist" if hwnd == 0
|
175
173
|
hwnd
|
176
174
|
when locators[:point]
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RAutomation
|
2
|
+
module Adapter
|
3
|
+
module MsUia
|
4
|
+
|
5
|
+
class TabControl < Control
|
6
|
+
class TabItem
|
7
|
+
attr_reader :text, :index
|
8
|
+
|
9
|
+
def initialize(tab_control, text, index)
|
10
|
+
@tab_control, @text, @index = tab_control, text, index
|
11
|
+
end
|
12
|
+
|
13
|
+
def select
|
14
|
+
UiaDll::select_tab(@tab_control.search_information, index)
|
15
|
+
end
|
16
|
+
|
17
|
+
def selected?
|
18
|
+
@index == UiaDll::tab_control_selected_index(@tab_control.search_information)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def select(index)
|
23
|
+
UiaDll::select_tab(search_information, index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def set(value)
|
27
|
+
UiaDll::select_tab(search_information, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def items
|
31
|
+
values.each_with_index.map {|value, index| TabItem.new(self, value, index) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def value
|
35
|
+
UiaDll::tab_selection(search_information)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def values
|
40
|
+
UiaDll::tab_items(search_information)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -189,6 +189,34 @@ module RAutomation
|
|
189
189
|
string_from(:SelectList_Selection, search_information)
|
190
190
|
end
|
191
191
|
|
192
|
+
# Tab Control methods
|
193
|
+
attach_function :TabControl_Items,
|
194
|
+
[SearchCriteria.by_ref, :pointer], :int
|
195
|
+
attach_function :TabControl_Selection,
|
196
|
+
[SearchCriteria.by_ref, :pointer, :int], :void
|
197
|
+
attach_function :TabControl_SelectByIndex,
|
198
|
+
[SearchCriteria.by_ref, :int, :pointer, :int], :void
|
199
|
+
attach_function :TabControl_SelectByValue,
|
200
|
+
[SearchCriteria.by_ref, :string, :pointer, :int], :void
|
201
|
+
attach_function :tab_control_selected_index, :TabControl_SelectedIndex, [SearchCriteria.by_ref], :int
|
202
|
+
|
203
|
+
def self.tab_items(search_information)
|
204
|
+
strings_from(:TabControl_Items, search_information)
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.tab_selection(search_information)
|
208
|
+
string_from(:TabControl_Selection, search_information)
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.select_tab(search_information, which)
|
212
|
+
case which
|
213
|
+
when Fixnum
|
214
|
+
can_throw(:TabControl_SelectByIndex, search_information, which)
|
215
|
+
when String
|
216
|
+
can_throw(:TabControl_SelectByValue, search_information, which)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
192
220
|
# Menu methods
|
193
221
|
attach_function :select_menu_item, :Menu_SelectPath,
|
194
222
|
[:long, :pointer, :int, :varargs], :void
|
@@ -252,8 +280,6 @@ module RAutomation
|
|
252
280
|
[:long], :pointer
|
253
281
|
attach_function :element_from_point, :RA_ElementFromPoint,
|
254
282
|
[:int, :int], :pointer
|
255
|
-
attach_function :find_child_by_id, :RA_FindChildById,
|
256
|
-
[:pointer, :string], :pointer
|
257
283
|
attach_function :current_native_window_handle, :RA_CurrentNativeWindowHandle,
|
258
284
|
[:pointer], :long
|
259
285
|
attach_function :move_mouse, :RA_MoveMouse,
|
@@ -164,6 +164,11 @@ module RAutomation
|
|
164
164
|
ValueControl.new(self, locator)
|
165
165
|
end
|
166
166
|
|
167
|
+
# @see TabControl#initialize
|
168
|
+
def tab_control(locator)
|
169
|
+
TabControl.new(self, locator)
|
170
|
+
end
|
171
|
+
|
167
172
|
# @see TextField#initialize
|
168
173
|
# @see RAutomation::Window#text_field
|
169
174
|
def text_field(locator)
|
@@ -3,6 +3,14 @@ require "spec_helper"
|
|
3
3
|
describe "MsUia::Control", :if => SpecHelper.adapter == :ms_uia do
|
4
4
|
let(:window) { RAutomation::Window.new(:title => /MainFormWindow/i) }
|
5
5
|
|
6
|
+
context '#click' do
|
7
|
+
it 'stops trying after the window goes away' do
|
8
|
+
window.button(:value => 'About').click { true }
|
9
|
+
|
10
|
+
RAutomation::Window.new(:title => 'About').button(:id => 'button1').click
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
it "control coordinates", :special => false do
|
7
15
|
window.maximize
|
8
16
|
control = window.control(:id => "radioButtonReset")
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include RAutomation::Adapter
|
4
|
+
|
5
|
+
describe MsUia::TabControl, :if => SpecHelper.adapter == :ms_uia do
|
6
|
+
let(:window) { RAutomation::Window.new(:title => 'MainFormWindow') }
|
7
|
+
let(:about) { RAutomation::Window.new(:title => 'About') }
|
8
|
+
subject { about.tab_control(:id => 'tabControl') }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
window.button(:value => 'About').click { true }
|
12
|
+
end
|
13
|
+
|
14
|
+
it { should exist }
|
15
|
+
|
16
|
+
it '#select' do
|
17
|
+
subject.select(1)
|
18
|
+
subject.value.should eq('More Info')
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#set' do
|
22
|
+
subject.set 'More Info'
|
23
|
+
subject.value.should eq('More Info')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has tab items' do
|
27
|
+
subject.items.count.should eq(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'knows the current tab' do
|
31
|
+
subject.value.should eq('Info')
|
32
|
+
end
|
33
|
+
|
34
|
+
context('#items') do
|
35
|
+
it 'has text' do
|
36
|
+
subject.items.map(&:text).should eq(['Info', 'More Info'])
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'has indices' do
|
40
|
+
subject.items.map(&:index).should eq([0, 1])
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can be selected' do
|
44
|
+
subject.items.find {|t| t.text == 'More Info'}.select
|
45
|
+
subject.value.should eq('More Info')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'knows if it is selected' do
|
49
|
+
subject.items.first.should be_selected
|
50
|
+
subject.items.last.should_not be_selected
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rautomation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarmo Pertman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -109,6 +109,8 @@ files:
|
|
109
109
|
- ext/UiaDll/UiaDll/AssemblyInfo.cpp
|
110
110
|
- ext/UiaDll/UiaDll/AutomatedSelectList.cpp
|
111
111
|
- ext/UiaDll/UiaDll/AutomatedSelectList.h
|
112
|
+
- ext/UiaDll/UiaDll/AutomatedTabControl.cpp
|
113
|
+
- ext/UiaDll/UiaDll/AutomatedTabControl.h
|
112
114
|
- ext/UiaDll/UiaDll/AutomatedTable.cpp
|
113
115
|
- ext/UiaDll/UiaDll/AutomatedTable.h
|
114
116
|
- ext/UiaDll/UiaDll/AutomatedText.cpp
|
@@ -132,6 +134,7 @@ files:
|
|
132
134
|
- ext/UiaDll/UiaDll/StringHelper.cpp
|
133
135
|
- ext/UiaDll/UiaDll/StringHelper.h
|
134
136
|
- ext/UiaDll/UiaDll/StringMethods.cpp
|
137
|
+
- ext/UiaDll/UiaDll/TabControlMethods.cpp
|
135
138
|
- ext/UiaDll/UiaDll/TableMethods.cpp
|
136
139
|
- ext/UiaDll/UiaDll/TextMethods.cpp
|
137
140
|
- ext/UiaDll/UiaDll/Toggle.cpp
|
@@ -202,6 +205,7 @@ files:
|
|
202
205
|
- lib/rautomation/adapter/ms_uia/menu.rb
|
203
206
|
- lib/rautomation/adapter/ms_uia/radio.rb
|
204
207
|
- lib/rautomation/adapter/ms_uia/select_list.rb
|
208
|
+
- lib/rautomation/adapter/ms_uia/tab_control.rb
|
205
209
|
- lib/rautomation/adapter/ms_uia/table.rb
|
206
210
|
- lib/rautomation/adapter/ms_uia/text_field.rb
|
207
211
|
- lib/rautomation/adapter/ms_uia/uia_dll.rb
|
@@ -243,6 +247,7 @@ files:
|
|
243
247
|
- spec/adapter/ms_uia/listbox_spec.rb
|
244
248
|
- spec/adapter/ms_uia/radio_spec.rb
|
245
249
|
- spec/adapter/ms_uia/select_list_spec.rb
|
250
|
+
- spec/adapter/ms_uia/tab_control_spec.rb
|
246
251
|
- spec/adapter/ms_uia/table_spec.rb
|
247
252
|
- spec/adapter/ms_uia/text_field_spec.rb
|
248
253
|
- spec/adapter/ms_uia/value_control_spec.rb
|
@@ -304,6 +309,7 @@ test_files:
|
|
304
309
|
- spec/adapter/ms_uia/listbox_spec.rb
|
305
310
|
- spec/adapter/ms_uia/radio_spec.rb
|
306
311
|
- spec/adapter/ms_uia/select_list_spec.rb
|
312
|
+
- spec/adapter/ms_uia/tab_control_spec.rb
|
307
313
|
- spec/adapter/ms_uia/table_spec.rb
|
308
314
|
- spec/adapter/ms_uia/text_field_spec.rb
|
309
315
|
- spec/adapter/ms_uia/value_control_spec.rb
|