OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Download utility test for Mac OS X. | 5 // Download utility test for Mac OS X. |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
10 #import "chrome/browser/cocoa/download_util_mac.h" | 10 #import "chrome/browser/cocoa/download_util_mac.h" |
11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class DownloadUtilTest : public CocoaTest { | 17 class DownloadUtilTest : public CocoaTest { |
18 public: | 18 public: |
19 DownloadUtilTest() { | 19 DownloadUtilTest() { |
20 pasteboard_ = [NSPasteboard pasteboardWithUniqueName]; | 20 pasteboard_ = [NSPasteboard pasteboardWithUniqueName]; |
21 } | 21 } |
22 | 22 |
23 virtual ~DownloadUtilTest() { | 23 virtual ~DownloadUtilTest() { |
24 [pasteboard_ releaseGlobally]; | 24 [pasteboard_ releaseGlobally]; |
25 } | 25 } |
26 | 26 |
27 const NSPasteboard* const pasteboard() { return pasteboard_; } | 27 NSPasteboard* const pasteboard() { return pasteboard_; } |
28 | 28 |
29 private: | 29 private: |
30 NSPasteboard* pasteboard_; | 30 NSPasteboard* pasteboard_; |
31 }; | 31 }; |
32 | 32 |
33 // Ensure adding files to the pasteboard methods works as expected. | 33 // Ensure adding files to the pasteboard methods works as expected. |
34 TEST_F(DownloadUtilTest, AddFileToPasteboardTest) { | 34 TEST_F(DownloadUtilTest, AddFileToPasteboardTest) { |
35 // Get a download test file for addition to the pasteboard. | 35 // Get a download test file for addition to the pasteboard. |
36 FilePath testPath; | 36 FilePath testPath; |
37 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &testPath)); | 37 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &testPath)); |
(...skipping 10 matching lines...) Expand all Loading... |
48 | 48 |
49 // Ensure the path is what we expect. | 49 // Ensure the path is what we expect. |
50 NSArray* files = [pasteboard() propertyListForType:NSFilenamesPboardType]; | 50 NSArray* files = [pasteboard() propertyListForType:NSFilenamesPboardType]; |
51 ASSERT_TRUE(files != nil); | 51 ASSERT_TRUE(files != nil); |
52 NSString* expectedPath = [files objectAtIndex:0]; | 52 NSString* expectedPath = [files objectAtIndex:0]; |
53 NSString* realPath = base::SysWideToNSString(testPath.ToWStringHack()); | 53 NSString* realPath = base::SysWideToNSString(testPath.ToWStringHack()); |
54 EXPECT_TRUE([expectedPath isEqualToString:realPath]); | 54 EXPECT_TRUE([expectedPath isEqualToString:realPath]); |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
OLD | NEW |