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

Side by Side Diff: chrome/browser/file_select_helper_unittest.cc

Issue 634833003: mac: Zip packages when they are selected by the file opener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 "base/files/file_path.h"
6 #include "base/files/file_util.h"
7 #include "base/path_service.h"
5 #include "chrome/browser/file_select_helper.h" 8 #include "chrome/browser/file_select_helper.h"
9 #include "chrome/common/chrome_paths.h"
6 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
7 11
8 TEST(FileSelectHelperTest, IsAcceptTypeValid) { 12 class FileSelectHelperTest : public testing::Test {
13 public:
14 FileSelectHelperTest() {}
15
16 protected:
17 virtual void SetUp() OVERRIDE {
18 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_));
19 data_dir_ = data_dir_.AppendASCII("file_select_helper");
20 ASSERT_TRUE(base::PathExists(data_dir_));
21 }
22
23 // The path to input data used in tests.
24 base::FilePath data_dir_;
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(FileSelectHelperTest);
28 };
29
30 TEST_F(FileSelectHelperTest, IsAcceptTypeValid) {
9 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("a/b")); 31 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("a/b"));
10 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("abc/def")); 32 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("abc/def"));
11 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("abc/*")); 33 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid("abc/*"));
12 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid(".a")); 34 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid(".a"));
13 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid(".abc")); 35 EXPECT_TRUE(FileSelectHelper::IsAcceptTypeValid(".abc"));
14 36
15 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid(".")); 37 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("."));
16 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("/")); 38 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("/"));
17 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("ABC/*")); 39 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("ABC/*"));
18 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("abc/def ")); 40 EXPECT_FALSE(FileSelectHelper::IsAcceptTypeValid("abc/def "));
19 } 41 }
42
43 #if defined(OS_MACOSX) && !defined(OS_IOS)
44 TEST_F(FileSelectHelperTest, ZipPackage) {
45 base::FilePath src = data_dir_.AppendASCII("CalculatorFake.app/");
46 base::FilePath dest = FileSelectHelper::ZipPackage(src);
47 EXPECT_FALSE(dest.empty());
48 EXPECT_TRUE(base::PathExists(dest));
49
50 base::FilePath expected_result =
51 data_dir_.AppendASCII("CalculatorFake.app.zip");
52 EXPECT_TRUE(base::ContentsEqual(dest, expected_result));
53
54 EXPECT_TRUE(base::DeleteFile(dest, false));
55 }
56 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698