summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/download_util_mac_unittest.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/download_util_mac_unittest.mm')
-rw-r--r--chrome/browser/cocoa/download_util_mac_unittest.mm25
1 files changed, 16 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/download_util_mac_unittest.mm b/chrome/browser/cocoa/download_util_mac_unittest.mm
index 0f61704..8d1939c 100644
--- a/chrome/browser/cocoa/download_util_mac_unittest.mm
+++ b/chrome/browser/cocoa/download_util_mac_unittest.mm
@@ -1,7 +1,7 @@
// Copyright (c) 2009 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.
-//
+
// Download utility test for Mac OS X.
#include "base/path_service.h"
@@ -16,14 +16,23 @@ namespace {
class DownloadUtilTest : public PlatformTest {
public:
+ DownloadUtilTest() {
+ pasteboard_ = [NSPasteboard pasteboardWithUniqueName];
+ }
+
+ virtual ~DownloadUtilTest() {
+ [pasteboard_ releaseGlobally];
+ }
+
+ const NSPasteboard* const pasteboard() { return pasteboard_; }
+
+ private:
CocoaTestHelper cocoa_helper_;
+ NSPasteboard* pasteboard_;
};
// Ensure adding files to the pasteboard methods works as expected.
TEST_F(DownloadUtilTest, AddFileToPasteboardTest) {
- // Create a pasteboard.
- NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName];
-
// Get a download test file for addition to the pasteboard.
FilePath testPath;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &testPath));
@@ -31,21 +40,19 @@ TEST_F(DownloadUtilTest, AddFileToPasteboardTest) {
testPath = testPath.Append(testFile);
// Add a test file to the pasteboard via the download_util method.
- download_util::AddFileToPasteboard(pasteboard, testPath);
+ download_util::AddFileToPasteboard(pasteboard(), testPath);
// Test to see that the object type for dragging files is available.
NSArray* types = [NSArray arrayWithObject:NSFilenamesPboardType];
- NSString* available = [pasteboard availableTypeFromArray:types];
+ NSString* available = [pasteboard() availableTypeFromArray:types];
EXPECT_TRUE(available != nil);
// Ensure the path is what we expect.
- NSArray* files = [pasteboard propertyListForType:NSFilenamesPboardType];
+ NSArray* files = [pasteboard() propertyListForType:NSFilenamesPboardType];
ASSERT_TRUE(files != nil);
NSString* expectedPath = [files objectAtIndex:0];
NSString* realPath = base::SysWideToNSString(testPath.ToWStringHack());
EXPECT_TRUE([expectedPath isEqualToString:realPath]);
-
- [pasteboard releaseGlobally];
}
} // namespace