Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8498)

Unified Diff: chrome/installer/mac/app/testing/Unpacker_test.mm

Issue 2203583002: Added unpacking step (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed some of Sidney's comments for the moment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/installer/mac/app/Unpacker.m ('K') | « chrome/installer/mac/app/Unpacker.m ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mac/app/testing/Unpacker_test.mm
diff --git a/chrome/installer/mac/app/testing/Unpacker_test.mm b/chrome/installer/mac/app/testing/Unpacker_test.mm
new file mode 100644
index 0000000000000000000000000000000000000000..352eccea97d8acf49da24513f45a2132b0588c40
--- /dev/null
+++ b/chrome/installer/mac/app/testing/Unpacker_test.mm
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/installer/mac/app/Unpacker.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#import "chrome/installer/mac/app/Downloader.h"
+
+extern dispatch_semaphore_t mount_semaphore;
+
+@interface TestDelegate : NSObject<UnpackDelegate>
+@end
+
+@implementation TestDelegate
+- (void)onUnpackSuccess {
+ NSFileManager* fileManager = [NSFileManager defaultManager];
+
+ if ([fileManager removeItemAtPath:@"/Applications/Google Chromo.app"
+ error:nil]) {
+ NSLog(@"Application removed!");
+ }
+
+ NSLog(@"test succeeded");
+ dispatch_semaphore_signal(mount_semaphore);
+}
+@end
+
+namespace {
+
+TEST(UnpackerTest, MountAndUnmount) {
+ Unpacker* unpack = [[Unpacker alloc] init];
+ TestDelegate* test_delegate = [[TestDelegate alloc] init];
+ unpack.delegate = test_delegate;
+ mount_semaphore = dispatch_semaphore_create(0);
+
+ [unpack mountDMG];
+ dispatch_semaphore_wait(mount_semaphore, DISPATCH_TIME_FOREVER);
+
+ DASessionRef session = DASessionCreate(nil);
+ DADiskRef child_disk = DADiskCreateFromVolumePath(
+ nil, session,
+ (CFURLRef)[NSURL URLWithString:PATH_FROM_EXECUTABLE(@"tmp")]);
+ DADiskRef whole_disk = DADiskCopyWholeDisk(child_disk);
+
+ CFDictionaryRef disk_dictionary = DADiskCopyDescription(whole_disk);
+ CFTypeRef mediaEjectableKey = CFDictionaryGetValue(
+ disk_dictionary, kDADiskDescriptionMediaEjectableKey);
+ ASSERT_TRUE(CFBooleanGetValue((CFBooleanRef)mediaEjectableKey));
+ CFRelease(whole_disk);
+ CFRelease(child_disk);
+
+ [unpack unmountDMG];
+ dispatch_semaphore_wait(mount_semaphore, DISPATCH_TIME_FOREVER);
+
+ DADiskRef disk_check = DADiskCreateFromVolumePath(
+ nil, session,
+ (CFURLRef)[NSURL URLWithString:PATH_FROM_EXECUTABLE(@"tmp")]);
+ EXPECT_FALSE(disk_check);
+}
+
+} // namespace
« chrome/installer/mac/app/Unpacker.m ('K') | « chrome/installer/mac/app/Unpacker.m ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698