mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-11-10 06:34:22 +00:00
GH Actions: Try to fix mic authorization dialog not closing.
This commit is contained in:
parent
cc2516a705
commit
30ec1c24b7
3 changed files with 61 additions and 34 deletions
3
.github/workflows/build-test-release.yml
vendored
3
.github/workflows/build-test-release.yml
vendored
|
@ -71,11 +71,13 @@ jobs:
|
|||
run: |
|
||||
echo '::group::BGMDriver Tests'
|
||||
xcodebuild \
|
||||
-quiet \
|
||||
-workspace BGM.xcworkspace \
|
||||
-scheme 'Background Music Device' \
|
||||
test
|
||||
echo '::group::BGMXPCHelper Tests'
|
||||
xcodebuild \
|
||||
-quiet \
|
||||
-workspace BGM.xcworkspace \
|
||||
-scheme 'BGMXPCHelper' \
|
||||
test
|
||||
|
@ -89,6 +91,7 @@ jobs:
|
|||
composedMessage contains[cd] "Background Music" or
|
||||
composedMessage contains "BGM"' > app.log &
|
||||
xcodebuild \
|
||||
-quiet \
|
||||
-workspace BGM.xcworkspace \
|
||||
-scheme 'Background Music' \
|
||||
test
|
||||
|
|
|
@ -211,36 +211,53 @@ NSString* const __nonnull kGenericOutputDeviceName = @"Output Device";
|
|||
// datasource, the device's name is set as this menu item's tooltip. Falls back to a generic name if
|
||||
// the device returns an error when queried.
|
||||
- (void) updateLabelAndToolTip {
|
||||
BOOL didSetLabel = NO;
|
||||
|
||||
try {
|
||||
if (outputDevice.HasDataSourceControl(kScope, kMasterChannel)) {
|
||||
// The device has datasources, so use the current datasource's name like macOS does.
|
||||
UInt32 dataSourceID = outputDevice.GetCurrentDataSourceID(kScope, kMasterChannel);
|
||||
|
||||
deviceLabel.stringValue =
|
||||
(__bridge_transfer NSString*)outputDevice.CopyDataSourceNameForID(kScope,
|
||||
kMasterChannel,
|
||||
dataSourceID);
|
||||
didSetLabel = YES; // So we know not to change the text if setting the tooltip fails.
|
||||
|
||||
// Set the tooltip of the menu item (the container) rather than the label because menu
|
||||
// items' tooltips will still appear when a different app is focused and, as far as I
|
||||
// know, BGMApp should never be the foreground app.
|
||||
self.toolTip = (__bridge_transfer NSString*)outputDevice.CopyName();
|
||||
} else {
|
||||
deviceLabel.stringValue = (__bridge_transfer NSString*)outputDevice.CopyName();
|
||||
self.toolTip = nil;
|
||||
}
|
||||
} catch (const CAException& e) {
|
||||
BGMLogException(e);
|
||||
|
||||
// The device returned an error, so set the label to a generic device name, since we don't
|
||||
// want to leave it set to the previous device's name.
|
||||
if (outputDevice.GetObjectID() == kAudioObjectUnknown) {
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: Output device unknown. Using the "
|
||||
"generic label.");
|
||||
self.toolTip = nil;
|
||||
deviceLabel.stringValue = kGenericOutputDeviceName;
|
||||
} else {
|
||||
BOOL didSetLabel = NO;
|
||||
|
||||
if (!didSetLabel) {
|
||||
deviceLabel.stringValue = kGenericOutputDeviceName;
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: Output device: %u",
|
||||
outputDevice.GetObjectID());
|
||||
|
||||
try {
|
||||
if (outputDevice.HasDataSourceControl(kScope, kMasterChannel)) {
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: Getting data source ID");
|
||||
// The device has datasources, so use the current datasource's name like macOS does.
|
||||
UInt32 dataSourceID = outputDevice.GetCurrentDataSourceID(kScope, kMasterChannel);
|
||||
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: "
|
||||
"Getting name for data source %u",
|
||||
dataSourceID);
|
||||
deviceLabel.stringValue =
|
||||
(__bridge_transfer NSString*)outputDevice.CopyDataSourceNameForID(
|
||||
kScope, kMasterChannel, dataSourceID);
|
||||
|
||||
// So we know not to change the text if setting the tooltip fails.
|
||||
didSetLabel = YES;
|
||||
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: Getting device name");
|
||||
// Set the tooltip of the menu item (the container) rather than the label because
|
||||
// menu items' tooltips will still appear when a different app is focused and, as
|
||||
// far as I know, BGMApp should never be the foreground app.
|
||||
self.toolTip = (__bridge_transfer NSString*)outputDevice.CopyName();
|
||||
} else {
|
||||
DebugMsg("BGMOutputVolumeMenuItem::updateLabelAndToolTip: Getting device name");
|
||||
deviceLabel.stringValue = (__bridge_transfer NSString*)outputDevice.CopyName();
|
||||
self.toolTip = nil;
|
||||
}
|
||||
} catch (const CAException& e) {
|
||||
BGMLogException(e);
|
||||
|
||||
// The device returned an error, so set the label to a generic device name, since we
|
||||
// don't want to leave it set to the previous device's name.
|
||||
self.toolTip = nil;
|
||||
|
||||
if (!didSetLabel) {
|
||||
deviceLabel.stringValue = kGenericOutputDeviceName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,20 +85,20 @@
|
|||
|
||||
[self acceptMicrophoneAuthorizationDialog];
|
||||
|
||||
if (![icon waitForExistenceWithTimeout:1.0]) {
|
||||
if (![icon waitForExistenceWithTimeout:20.0]) {
|
||||
// The status bar icon/button has this type when using older versions of XCTest, so try
|
||||
// both. (Actually, it might depend on the macOS or Xcode version. I'm not sure.)
|
||||
XCUIElement* iconOldType =
|
||||
[app.menuBars childrenMatchingType:XCUIElementTypeMenuBarItem].element;
|
||||
if ([iconOldType waitForExistenceWithTimeout:5.0]) {
|
||||
if ([iconOldType waitForExistenceWithTimeout:20.0]) {
|
||||
NSLog(@"icon = iconOldType");
|
||||
icon = iconOldType;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the initial elements.
|
||||
XCTAssert([app waitForExistenceWithTimeout:10.0]);
|
||||
XCTAssert([icon waitForExistenceWithTimeout:10.0]);
|
||||
XCTAssert([app waitForExistenceWithTimeout:20.0]);
|
||||
XCTAssert([icon waitForExistenceWithTimeout:20.0]);
|
||||
}
|
||||
|
||||
// Clicks the OK button in the "Background Music wants to use the microphone" dialog.
|
||||
|
@ -108,11 +108,18 @@
|
|||
NSLog(@"UserNotificationCenter: %@", unc);
|
||||
XCUIElement* okButton = unc.dialogs.buttons[@"OK"];
|
||||
|
||||
XCTAssert([okButton waitForExistenceWithTimeout:10.0]);
|
||||
XCTAssert([okButton waitForExistenceWithTimeout:20.0]);
|
||||
|
||||
// This click is failing on GH Actions. No idea why, so try a sleep.
|
||||
(void)[XCTWaiter waitForExpectations:@[[XCTestExpectation new]] timeout:2.0];
|
||||
(void)[XCTWaiter waitForExpectations:@[[XCTestExpectation new]] timeout:5.0];
|
||||
[okButton click];
|
||||
|
||||
int retries = 10;
|
||||
while (retries > 0 && [okButton waitForExistenceWithTimeout:3.0]) {
|
||||
NSLog(@"Microphone authorization dialog is still open. Trying to click OK again.");
|
||||
[okButton click];
|
||||
retries--;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) tearDown {
|
||||
|
|
Loading…
Reference in a new issue