Skip to content
Open
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
12 changes: 12 additions & 0 deletions MorphicManualTester/MorphicManualTester/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ struct ContentView: View {
Button(action: registry.loadSolution) {
Text("Load a Different Registry")
}
Button(action: registry.testWordEBasic) {
Text("EBasic")
}
Button(action: registry.testWordDBasic) {
Text("DBasic")
}
Button(action: registry.testWordEEssentials) {
Text("EEssen")
}
Button(action: registry.testWordDEssentials) {
Text("DEssen")
}
.padding([.top, .bottom, .trailing])
}
.padding(.vertical, 0.0)
Expand Down
23 changes: 23 additions & 0 deletions MorphicManualTester/MorphicManualTester/RegistryManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,29 @@ class RegistryManager: ObservableObject
load = "NO REGISTRY LOADED"
autoApply = true
solutions = [SolutionCollection]()
word = MorphicWord()
}

private var word: MorphicWord

func testWordRefresh() {
WordRibbonUIAutomation.RefreshRibbon()
}

func testWordEBasic() {
word.enableBasicsTab()
}

func testWordDBasic() {
word.disableBasicsTab()
}

func testWordEEssentials() {
word.enableEssentialsTab()
}

func testWordDEssentials() {
word.disableEssentialsTab()
}

func loadSolution() {
Expand Down
36 changes: 36 additions & 0 deletions MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
9DD4F4A42517B0F200ADCC25 /* LanguageAndRegionPreferencesElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD4F4A32517B0F200ADCC25 /* LanguageAndRegionPreferencesElement.swift */; };
9DE45B962517114100209421 /* DisplaysUIAutomation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE45B952517114100209421 /* DisplaysUIAutomation.swift */; };
9DE45B9F251712EB00209421 /* DisplaysPreferencesElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE45B9E251712EB00209421 /* DisplaysPreferencesElement.swift */; };
DF98E14D267D79D0000D730A /* EmptyTemplate.xml in Resources */ = {isa = PBXBuildFile; fileRef = DF98E14B267D79D0000D730A /* EmptyTemplate.xml */; };
DF98E14E267D79D0000D730A /* ComponentTemplate.xml in Resources */ = {isa = PBXBuildFile; fileRef = DF98E14C267D79D0000D730A /* ComponentTemplate.xml */; };
DFF3F9F7265DEA52001F0430 /* WordRibbonUIAutomations.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF3F9F6265DEA52001F0430 /* WordRibbonUIAutomations.swift */; };
DFF3F9FE265F4EC8001F0430 /* WordApplicationElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF3F9FD265F4EC8001F0430 /* WordApplicationElement.swift */; };
DFF3FA042669D8F3001F0430 /* MorphicWord.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFF3FA032669D8F3001F0430 /* MorphicWord.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -190,6 +195,11 @@
9DD4F4A32517B0F200ADCC25 /* LanguageAndRegionPreferencesElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageAndRegionPreferencesElement.swift; sourceTree = "<group>"; };
9DE45B952517114100209421 /* DisplaysUIAutomation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplaysUIAutomation.swift; sourceTree = "<group>"; };
9DE45B9E251712EB00209421 /* DisplaysPreferencesElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplaysPreferencesElement.swift; sourceTree = "<group>"; };
DF98E14B267D79D0000D730A /* EmptyTemplate.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = EmptyTemplate.xml; sourceTree = "<group>"; };
DF98E14C267D79D0000D730A /* ComponentTemplate.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ComponentTemplate.xml; sourceTree = "<group>"; };
DFF3F9F6265DEA52001F0430 /* WordRibbonUIAutomations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordRibbonUIAutomations.swift; sourceTree = "<group>"; };
DFF3F9FD265F4EC8001F0430 /* WordApplicationElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordApplicationElement.swift; sourceTree = "<group>"; };
DFF3FA032669D8F3001F0430 /* MorphicWord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MorphicWord.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -252,6 +262,7 @@
9DD22FB924DCB8B800C2FA52 /* SpeechUIAutomations.swift */,
31F9AEE224A7F7EA0026EBDA /* VoiceOverUIAutomations.swift */,
31F9AEE424A803B90026EBDA /* ZoomUIAutomations.swift */,
DFF3F9F6265DEA52001F0430 /* WordRibbonUIAutomations.swift */,
);
path = Automations;
sourceTree = "<group>";
Expand Down Expand Up @@ -325,6 +336,7 @@
31A0A5792405967600166668 /* MorphicSettings */ = {
isa = PBXGroup;
children = (
DFF3FA022669D8CE001F0430 /* Office */,
9D0AF73524A0FB49007E177E /* AccessibilityUI */,
314EB6DC24A6A65F00CF3D48 /* Automations */,
31A16BC72423E86C0081A72C /* Audio */,
Expand Down Expand Up @@ -438,6 +450,7 @@
3137AC4524B0FC0D00CE3808 /* Menus */,
315EECA024A5839F0039C61D /* Tables */,
315EECA324A583C00039C61D /* SystemPrefs */,
DFF3F9FC265F4E98001F0430 /* OtherApps */,
);
path = AccessibilityUI;
sourceTree = "<group>";
Expand All @@ -462,6 +475,24 @@
path = PropertyList;
sourceTree = "<group>";
};
DFF3F9FC265F4E98001F0430 /* OtherApps */ = {
isa = PBXGroup;
children = (
DFF3F9FD265F4EC8001F0430 /* WordApplicationElement.swift */,
);
path = OtherApps;
sourceTree = "<group>";
};
DFF3FA022669D8CE001F0430 /* Office */ = {
isa = PBXGroup;
children = (
DF98E14C267D79D0000D730A /* ComponentTemplate.xml */,
DF98E14B267D79D0000D730A /* EmptyTemplate.xml */,
DFF3FA032669D8F3001F0430 /* MorphicWord.swift */,
);
path = Office;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -561,6 +592,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DF98E14D267D79D0000D730A /* EmptyTemplate.xml in Resources */,
DF98E14E267D79D0000D730A /* ComponentTemplate.xml in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -595,6 +628,7 @@
31F9AEEC24AA54BF0026EBDA /* PopUpButtonElement.swift in Sources */,
31F9AEE524A803B90026EBDA /* ZoomUIAutomations.swift in Sources */,
9DD4F4A42517B0F200ADCC25 /* LanguageAndRegionPreferencesElement.swift in Sources */,
DFF3F9FE265F4EC8001F0430 /* WordApplicationElement.swift in Sources */,
312DBFF024A27BCF002FB951 /* Solution.swift in Sources */,
31A16BCB2423E86C0081A72C /* MorphicLaunchDaemonsAndAgents.swift in Sources */,
314EB6E224A6B34300CF3D48 /* TabElement.swift in Sources */,
Expand Down Expand Up @@ -626,6 +660,7 @@
9DD4F49A2517AF1600ADCC25 /* KeyboardPreferencesElement.swift in Sources */,
9D4B24BF25143D0000F0B2E2 /* GeneralUIAutomations.swift in Sources */,
31CE56E22448C8F700A52A7B /* SettingHandler.swift in Sources */,
DFF3FA042669D8F3001F0430 /* MorphicWord.swift in Sources */,
315EEC8724A536A60039C61D /* TabGroupElement.swift in Sources */,
9DD22FBA24DCB8B800C2FA52 /* SpeechUIAutomations.swift in Sources */,
9DE45B962517114100209421 /* DisplaysUIAutomation.swift in Sources */,
Expand All @@ -639,6 +674,7 @@
312DBFFB24A2C66A002FB951 /* ApplySession.swift in Sources */,
314EB6DE24A6A67700CF3D48 /* UIAutomation.swift in Sources */,
9DE45B9F251712EB00209421 /* DisplaysPreferencesElement.swift in Sources */,
DFF3F9F7265DEA52001F0430 /* WordRibbonUIAutomations.swift in Sources */,
312DBFF324A28556002FB951 /* DefaultsReadUIWriteSettingHandler.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class ApplicationElement: UIElement {
open(hide: true, completion: completion)
}

public func open(hide: Bool, completion: @escaping (_ success: Bool) -> Void) {
public func open(hide: Bool, attachOnly: Bool = false, completion: @escaping (_ success: Bool) -> Void) {
guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleIdentifier) else {
os_log(.error, log: logger, "Failed to find url for application %{public}s", bundleIdentifier)
completion(false)
Expand Down Expand Up @@ -96,6 +96,10 @@ public class ApplicationElement: UIElement {
}
runningApplication = NSRunningApplication.runningApplications(withBundleIdentifier: bundleIdentifier).first
if runningApplication == nil {
if(attachOnly) {
completion(false)
return
}
MorphicProcess.openProcess(at: url, arguments: [], activate: false, hide: hide) {
(runningApplication, error) in
DispatchQueue.main.async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public struct MorphicA11yUIElement {
// role
// https://developer.apple.com/documentation/appkit/nsaccessibility/role
public let role: NSAccessibility.Role
//
// subrole
// https://develpoer.apple.com/documentation/appkit/nsaccessibility/subrole
public let subrole: NSAccessibility.Subrole

internal init?(axUiElement: AXUIElement) {
// axUiElement
Expand All @@ -57,12 +61,22 @@ public struct MorphicA11yUIElement {
// role
if self.supportedAttributes.contains(.role) == true {
guard let roleAsString: String = MorphicA11yUIElement.value(forAttribute: .role, forAXUIElement: self.axUiElement) else {
return nil
return nil
}
self.role = NSAccessibility.Role(rawValue: roleAsString)
} else {
self.role = .unknown
}
//
// role
if self.supportedAttributes.contains(.subrole) == true {
guard let subroleAsString: String = MorphicA11yUIElement.value(forAttribute: .subrole, forAXUIElement: self.axUiElement) else {
return nil
}
self.subrole = NSAccessibility.Subrole(rawValue: subroleAsString)
} else {
self.subrole = .unknown
}
}

public static func createFromProcess(processIdentifier: pid_t) throws -> MorphicA11yUIElement? {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2020 Raising the Floor - International
//
// Licensed under the New BSD license. You may not use this file except in
// compliance with this License.
//
// You may obtain a copy of the License at
// https://github.com/GPII/universal/blob/master/LICENSE.txt
//
// The R&D leading to these results received funding from the:
// * Rehabilitation Services Administration, US Dept. of Education under
// grant H421A150006 (APCP)
// * National Institute on Disability, Independent Living, and
// Rehabilitation Research (NIDILRR)
// * Administration for Independent Living & Dept. of Education under grants
// H133E080022 (RERC-IT) and H133E130028/90RE5003-01-00 (UIITA-RERC)
// * European Union's Seventh Framework Programme (FP7/2007-2013) grant
// agreement nos. 289016 (Cloud4all) and 610510 (Prosperity4All)
// * William and Flora Hewlett Foundation
// * Ontario Ministry of Research and Innovation
// * Canadian Foundation for Innovation
// * Adobe Foundation
// * Consumer Electronics Association Foundation

import Foundation
import MorphicCore

public class WordApplicationElement: ApplicationElement {

public static let bundleIdentifier = "com.microsoft.Word"

public init() {
super.init(bundleIdentifier: WordApplicationElement.bundleIdentifier)
}

public required init(accessibilityElement: MorphicA11yUIElement?) {
fatalError("init(accessibilityElement:) has not been implemented")
}
}
25 changes: 24 additions & 1 deletion MorphicSettings/MorphicSettings/AccessibilityUI/UIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class UIElement {
return descendant(role: .checkBox, title: titled)
}

public func firstCheckbox() -> CheckboxElement? {
return descendant(role: .checkBox)
}

public func table(titled: String) -> TableElement? {
return descendant(role: .table, title: titled)
}
Expand Down Expand Up @@ -80,7 +84,7 @@ public class UIElement {
}

private func descendant<ElementType: UIElement>(role: NSAccessibility.Role, title: String) -> ElementType? {
guard let accessibilityElement = accessibilityDescendant(role: role, title: title) else {
guard let accessibilityElement = accessibilityDescendant(role: role, title: title) else {
return nil
}
return ElementType(accessibilityElement: accessibilityElement)
Expand Down Expand Up @@ -165,6 +169,25 @@ public class UIElement {
}
return nil
}

public func closeButton() -> MorphicA11yUIElement? {
guard let children = accessibilityElement.children() else {
return nil
}
var stack = children
var i = 0
while i < stack.count {
let candidate = stack[i]
if candidate.subrole == NSAccessibility.Subrole.closeButton {
return candidate
}
if let children = candidate.children() {
stack.append(contentsOf: children)
}
i += 1
}
return nil
}

public func perform(action: Action, completion: @escaping (_ success: Bool, _ nextTarget: UIElement?) -> Void) {
switch action {
Expand Down
Loading