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

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

Issue 9426030: Mac: Enable WebAppShortcutCreatorTest.CreateShortcut unit test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace fixes 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
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.mm ('k') | chrome/common/mac/app_mode_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "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"
(...skipping 11 matching lines...) Expand all
22 22
23 class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator { 23 class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator {
24 public: 24 public:
25 explicit WebAppShortcutCreatorMock( 25 explicit WebAppShortcutCreatorMock(
26 const ShellIntegration::ShortcutInfo& shortcut_info) 26 const ShellIntegration::ShortcutInfo& shortcut_info)
27 : WebAppShortcutCreator(shortcut_info, 27 : WebAppShortcutCreator(shortcut_info,
28 UTF8ToUTF16("fake.cfbundleidentifier")) { 28 UTF8ToUTF16("fake.cfbundleidentifier")) {
29 } 29 }
30 30
31 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&)); 31 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&));
32 MOCK_CONST_METHOD1(RevealGeneratedBundleInFinder, void(const FilePath&));
32 }; 33 };
33 34
34 ShellIntegration::ShortcutInfo GetShortcutInfo() { 35 ShellIntegration::ShortcutInfo GetShortcutInfo() {
35 ShellIntegration::ShortcutInfo info; 36 ShellIntegration::ShortcutInfo info;
36 info.extension_id = "extension_id"; 37 info.extension_id = "extension_id";
37 info.title = ASCIIToUTF16("Shortcut Title"); 38 info.title = ASCIIToUTF16("Shortcut Title");
38 info.url = GURL("http://example.com/"); 39 info.url = GURL("http://example.com/");
39 return info; 40 return info;
40 } 41 }
41 42
42 // This test is disabled for the following reasons: 43 TEST(WebAppShortcutCreatorTest, CreateShortcut) {
43 // * The plist still isn't filled in correctly.
44 // * WebAppShortcutCreator::CreateShortcut() opens a Finder window which it
45 // shouldn't be doing when run from a unit test.
46 TEST(WebAppShortcutCreatorTest, DISABLED_CreateShortcut) {
47 ScopedTempDir scoped_temp_dir; 44 ScopedTempDir scoped_temp_dir;
48 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); 45 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
49 FilePath dst_path = scoped_temp_dir.path().Append("a.app"); 46 FilePath dst_path = scoped_temp_dir.path().Append("a.app");
50 47
51 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); 48 ShellIntegration::ShortcutInfo info = GetShortcutInfo();
52 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); 49 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info);
53 EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) 50 EXPECT_CALL(shortcut_creator, GetDestinationPath(_))
54 .WillRepeatedly(Return(dst_path)); 51 .WillRepeatedly(Return(dst_path));
52 EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path));
sail 2012/02/20 17:47:11 why do you need this?
jeremy 2012/02/21 13:22:36 To make sure that the function is called with the
53
55 EXPECT_TRUE(shortcut_creator.CreateShortcut()); 54 EXPECT_TRUE(shortcut_creator.CreateShortcut());
56 EXPECT_TRUE(file_util::PathExists(dst_path)); 55 EXPECT_TRUE(file_util::PathExists(dst_path));
57 56
58 FilePath plist_path = dst_path.Append("Contents").Append("Info.plist"); 57 FilePath plist_path = dst_path.Append("Contents").Append("Info.plist");
59 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: 58 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile:
60 base::mac::FilePathToNSString(plist_path)]; 59 base::mac::FilePathToNSString(plist_path)];
61 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id), 60 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id),
62 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); 61 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]);
63 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title), 62 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title),
64 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); 63 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]);
(...skipping 12 matching lines...) Expand all
77 } 76 }
78 77
79 TEST(WebAppShortcutCreatorTest, CreateFailure) { 78 TEST(WebAppShortcutCreatorTest, CreateFailure) {
80 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(GetShortcutInfo()); 79 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(GetShortcutInfo());
81 EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) 80 EXPECT_CALL(shortcut_creator, GetDestinationPath(_))
82 .WillRepeatedly(Return(FilePath("/non-existant/path/"))); 81 .WillRepeatedly(Return(FilePath("/non-existant/path/")));
83 EXPECT_FALSE(shortcut_creator.CreateShortcut()); 82 EXPECT_FALSE(shortcut_creator.CreateShortcut());
84 } 83 }
85 84
86 } // namespace 85 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.mm ('k') | chrome/common/mac/app_mode_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698