Skip to content

Commit c03dc20

Browse files
committed
Characterize manual refs refresh and native resizing
gitx/gitx#404 gitx/gitx#400
1 parent 9b9e5fe commit c03dc20

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎GitXTests/GitXCoreTests.m‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ - (void)testCreateReloadAndDeleteBranchAndTag
277277
XCTAssertFalse([self.repository refExists:tag]);
278278
}
279279

280+
- (void)testManualRevisionRefreshReloadsExternallyChangedHeadAndBranches
281+
{
282+
NSError *error = nil;
283+
[self.repository readCurrentBranch];
284+
XCTAssertEqualObjects(self.repository.currentBranch.simpleRef, @"refs/heads/main");
285+
XCTAssertNotNil(([self.fixture git:@[ @"checkout", @"--quiet", @"-b", @"feature/manual-refresh" ] error:&error]), @"%@", error);
286+
287+
[self.repository forceUpdateRevisions];
288+
289+
XCTAssertEqualObjects(self.repository.headRef.simpleRef, @"refs/heads/feature/manual-refresh");
290+
XCTAssertNotNil([self.repository refForName:@"feature/manual-refresh"]);
291+
XCTAssertEqualObjects(self.repository.currentBranch.simpleRef, @"refs/heads/main");
292+
}
293+
280294
- (void)testRemoteDiscoveryUsesLocalFixture
281295
{
282296
NSError *error = nil;

‎GitXTests/GitXFeatureTests.m‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "PBFileChangesTableView.h"
1111
#import "PBNativeContentView.h"
1212
#import "PBTask.h"
13+
#import "PBWebController.h"
1314
#import "NSAppearance+PBDarkMode.h"
1415

1516
@interface PBFileChangesActionTarget : NSObject <NSTableViewDataSource, NSTableViewDelegate, PBFileChangesTableViewStagingDelegate>
@@ -263,6 +264,24 @@ - (void)testNativeDiffCombinesSyntaxAndDiffHighlighting
263264
XCTAssertNotNil([storage attribute:NSBackgroundColorAttributeName atIndex:textLine.location + 1 effectiveRange:nil]);
264265
}
265266

267+
- (void)testNativeHistoryContentTracksHostBoundsWhileResizing
268+
{
269+
NSView *host = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 700, 420)];
270+
PBWebController *controller = [[PBWebController alloc] init];
271+
controller.view = host;
272+
[controller awakeFromNib];
273+
[controller.nativeView showMessage:@"Resize-safe history content"];
274+
275+
for (NSValue *sizeValue in @[ [NSValue valueWithSize:NSMakeSize(360, 240)], [NSValue valueWithSize:NSMakeSize(980, 640)], [NSValue valueWithSize:NSMakeSize(520, 300)] ]) {
276+
host.frameSize = sizeValue.sizeValue;
277+
[host layoutSubtreeIfNeeded];
278+
XCTAssertTrue(NSEqualRects(controller.nativeView.frame, host.bounds));
279+
XCTAssertTrue([controller.nativeView.textView.string containsString:@"Resize-safe history content"]);
280+
}
281+
282+
[controller closeView];
283+
}
284+
266285
- (void)testNativeDiffAlwaysRendersLargePatches
267286
{
268287
PBNativeContentView *view = [[PBNativeContentView alloc] initWithFrame:NSMakeRect(0, 0, 500, 300)];

0 commit comments

Comments
 (0)