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

Side by Side Diff: chrome/browser/web_applications/web_app_mac_unittest.mm

Issue 9416012: Mac: Generate App Mode Loader bundle + cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/web_applications/web_app_mac.h" 5 #import "chrome/browser/web_applications/web_app_mac.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/common/mac/app_mode_common.h" 12 #include "chrome/common/mac/app_mode_common.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #import "testing/gtest_mac.h" 15 #import "testing/gtest_mac.h"
(...skipping 15 matching lines...) Expand all
31 }; 31 };
32 32
33 ShellIntegration::ShortcutInfo GetShortcutInfo() { 33 ShellIntegration::ShortcutInfo GetShortcutInfo() {
34 ShellIntegration::ShortcutInfo info; 34 ShellIntegration::ShortcutInfo info;
35 info.extension_id = "extension_id"; 35 info.extension_id = "extension_id";
36 info.title = ASCIIToUTF16("Shortcut Title"); 36 info.title = ASCIIToUTF16("Shortcut Title");
37 info.url = GURL("http://example.com/"); 37 info.url = GURL("http://example.com/");
38 return info; 38 return info;
39 } 39 }
40 40
41 // This test currently fails because the Mac app loader isn't built yet. 41 // This test is disabled for the following reasons:
42 TEST(WebAppShortcutCreatorTest, FAILS_CreateShortcut) { 42 // * The plist still isn't filled in correctly.
43 // * WebAppShortcutCreator::CreateShortcut() opens a Finder window which it
44 // shouldn't be doing when run from a unit test.
45 TEST(WebAppShortcutCreatorTest, DISABLED_CreateShortcut) {
jeremy 2012/02/16 12:55:34 Sorry I'm not fixing the test as part of this CL b
43 ScopedTempDir scoped_temp_dir; 46 ScopedTempDir scoped_temp_dir;
44 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); 47 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
45 FilePath dst_path = scoped_temp_dir.path().Append("a.app"); 48 FilePath dst_path = scoped_temp_dir.path().Append("a.app");
46 49
47 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); 50 ShellIntegration::ShortcutInfo info = GetShortcutInfo();
48 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); 51 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info);
49 EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) 52 EXPECT_CALL(shortcut_creator, GetDestinationPath(_))
50 .WillRepeatedly(Return(dst_path)); 53 .WillRepeatedly(Return(dst_path));
51 EXPECT_TRUE(shortcut_creator.CreateShortcut()); 54 EXPECT_TRUE(shortcut_creator.CreateShortcut(@"fake.cfbundleidentifier"));
52 EXPECT_TRUE(file_util::PathExists(dst_path)); 55 EXPECT_TRUE(file_util::PathExists(dst_path));
53 56
54 FilePath plist_path = dst_path.Append("Contents").Append("Info.plist"); 57 FilePath plist_path = dst_path.Append("Contents").Append("Info.plist");
55 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: 58 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile:
56 base::mac::FilePathToNSString(plist_path)]; 59 base::mac::FilePathToNSString(plist_path)];
57 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id), 60 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id),
58 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); 61 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]);
59 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title), 62 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title),
60 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); 63 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]);
61 EXPECT_NSEQ(base::SysUTF8ToNSString(info.url.spec()), 64 EXPECT_NSEQ(base::SysUTF8ToNSString(info.url.spec()),
62 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); 65 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]);
63 66
64 // Make sure all values in the plist are actually filled in. 67 // Make sure all values in the plist are actually filled in.
65 for (NSString* value in [plist allValues]) 68 for (id key in plist) {
66 EXPECT_FALSE([value hasPrefix:@"@APP_"]); 69 id value = [plist valueForKey:key];
70 if (![value isKindOfClass:[NSString class]])
71 continue;
72
73 EXPECT_EQ([value rangeOfString:@"@APP_"].location, NSNotFound)
74 << [key UTF8String] << ":" << [value UTF8String];
75 }
67 } 76 }
68 77
69 TEST(WebAppShortcutCreatorTest, CreateFailure) { 78 TEST(WebAppShortcutCreatorTest, DISABLED_CreateFailure) {
sail 2012/02/17 16:42:09 Is this failing now? If so can you put a comment a
jeremy 2012/02/19 14:36:41 You're right, reverted.
70 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(GetShortcutInfo()); 79 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(GetShortcutInfo());
71 EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) 80 EXPECT_CALL(shortcut_creator, GetDestinationPath(_))
72 .WillRepeatedly(Return(FilePath("/non-existant/path/"))); 81 .WillRepeatedly(Return(FilePath("/non-existant/path/")));
73 EXPECT_FALSE(shortcut_creator.CreateShortcut()); 82 EXPECT_FALSE(shortcut_creator.CreateShortcut(@"fake.cfbundleidentifier"));
74 } 83 }
75 84
76 } // namespace 85 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698