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

Side by Side 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: Added use of temporary folders, removed semaphore from main installer code, adjusted some files' APIs, resolved remaining comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/installer/mac/app/Unpacker.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 #import "chrome/installer/mac/app/Downloader.h"
10
11 dispatch_semaphore_t mount_semaphore;
12
13 @interface TestDelegate : NSObject<UnpackDelegate>
14 @end
15
16 @implementation TestDelegate
17 - (void)onUnpackSuccess {
18 NSFileManager* fileManager = [NSFileManager defaultManager];
19
20 if ([fileManager removeItemAtPath:@"/Applications/Google Chromo.app"
Elly Fong-Jones 2016/08/16 15:26:18 Chrome :)
Anna Zeng 2016/08/16 23:07:40 Acknowledged.
21 error:nil]) {
22 NSLog(@"Application removed!");
23 }
24
25 NSLog(@"test succeeded");
26 dispatch_semaphore_signal(mount_semaphore);
27 }
28 @end
29
30 namespace {
31
32 // TODO: edit the below test to work with the current protocol
33 TEST(UnpackerTest, MountAndUnmount) {
34 Unpacker* unpack = [[Unpacker alloc]
35 // NOTE: purposefully misspelled Chrome in order to avoid overwriting the
36 // current machine's Google Chrome installation.
37 initWithFinalAppPath:@"/Applications/Google Chromo.app"];
Sidney San Martín 2016/08/13 12:37:19 It would be better if the test used a temporary fo
Anna Zeng 2016/08/16 23:07:40 Good point! Done.
38 TestDelegate* test_delegate = [[TestDelegate alloc] init];
39 unpack.delegate = test_delegate;
40 mount_semaphore = dispatch_semaphore_create(0);
41
42 [unpack mountDMG];
43
44 DASessionRef session = DASessionCreate(nil);
45 DADiskRef child_disk = DADiskCreateFromVolumePath(
46 nil, session,
47 (CFURLRef)[NSURL URLWithString:PATH_FROM_EXECUTABLE(@"tmp")]);
48 DADiskRef whole_disk = DADiskCopyWholeDisk(child_disk);
49
50 CFDictionaryRef disk_dictionary = DADiskCopyDescription(whole_disk);
51 CFTypeRef mediaEjectableKey = CFDictionaryGetValue(
52 disk_dictionary, kDADiskDescriptionMediaEjectableKey);
53 ASSERT_TRUE(CFBooleanGetValue((CFBooleanRef)mediaEjectableKey));
Sidney San Martín 2016/08/13 12:37:19 It would be way simpler to just look for a file (l
Anna Zeng 2016/08/16 23:07:40 Done.
54 CFRelease(whole_disk);
55 CFRelease(child_disk);
56
57 [unpack unmountDMG];
58 dispatch_semaphore_wait(mount_semaphore, DISPATCH_TIME_FOREVER);
59
60 DADiskRef disk_check = DADiskCreateFromVolumePath(
61 nil, session,
62 (CFURLRef)[NSURL URLWithString:PATH_FROM_EXECUTABLE(@"tmp")]);
63 EXPECT_FALSE(disk_check);
Sidney San Martín 2016/08/13 12:37:19 Ditto.
Anna Zeng 2016/08/16 23:07:40 Done.
64 }
65
66 } // namespace
OLDNEW
« 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