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

Side by Side Diff: chrome/installer/util/shell_util_unittest.cc

Issue 669943003: shell_util: AddFileAssociations now correctly quotes "%1" arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « chrome/installer/util/shell_util.cc ('k') | no next file » | 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 #include "chrome/installer/util/shell_util.h" 5 #include "chrome/installer/util/shell_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/base_paths_win.h" 10 #include "base/base_paths_win.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 base::win::RegKey key; 818 base::win::RegKey key;
819 ASSERT_EQ( 819 ASSERT_EQ(
820 ERROR_SUCCESS, 820 ERROR_SUCCESS,
821 key.Create( 821 key.Create(
822 HKEY_CURRENT_USER, L"Software\\Classes\\.test2", KEY_ALL_ACCESS)); 822 HKEY_CURRENT_USER, L"Software\\Classes\\.test2", KEY_ALL_ACCESS));
823 EXPECT_EQ(ERROR_SUCCESS, key.WriteValue(L"", L"SomeOtherApp")); 823 EXPECT_EQ(ERROR_SUCCESS, key.WriteValue(L"", L"SomeOtherApp"));
824 } 824 }
825 825
826 static base::CommandLine OpenCommand() { 826 static base::CommandLine OpenCommand() {
827 base::FilePath open_command_path(kTestOpenCommand); 827 base::FilePath open_command_path(kTestOpenCommand);
828 return base::CommandLine(open_command_path); 828 base::CommandLine open_command(open_command_path);
829 // The "%1" should automatically be quoted.
830 open_command.AppendArg("%1");
831 return open_command;
829 } 832 }
830 833
831 static std::set<base::string16> FileExtensions() { 834 static std::set<base::string16> FileExtensions() {
832 std::set<base::string16> file_extensions; 835 std::set<base::string16> file_extensions;
833 for (size_t i = 0; i < arraysize(kTestFileExtensions); ++i) 836 for (size_t i = 0; i < arraysize(kTestFileExtensions); ++i)
834 file_extensions.insert(kTestFileExtensions[i]); 837 file_extensions.insert(kTestFileExtensions[i]);
835 return file_extensions; 838 return file_extensions;
836 } 839 }
837 840
838 private: 841 private:
(...skipping 22 matching lines...) Expand all
861 key.Open(HKEY_CURRENT_USER, 864 key.Open(HKEY_CURRENT_USER,
862 L"Software\\Classes\\TestApp\\DefaultIcon", 865 L"Software\\Classes\\TestApp\\DefaultIcon",
863 KEY_READ)); 866 KEY_READ));
864 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value)); 867 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value));
865 EXPECT_EQ(L"D:\\test.ico,0", value); 868 EXPECT_EQ(L"D:\\test.ico,0", value);
866 ASSERT_EQ(ERROR_SUCCESS, 869 ASSERT_EQ(ERROR_SUCCESS,
867 key.Open(HKEY_CURRENT_USER, 870 key.Open(HKEY_CURRENT_USER,
868 L"Software\\Classes\\TestApp\\shell\\open\\command", 871 L"Software\\Classes\\TestApp\\shell\\open\\command",
869 KEY_READ)); 872 KEY_READ));
870 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value)); 873 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value));
871 EXPECT_EQ(L"\"C:\\test.exe\"", value); 874 EXPECT_EQ(L"\"C:\\test.exe\" \"%1\"", value);
872 875
873 // .test1 should be default-associated with our test app. 876 // .test1 should be default-associated with our test app.
874 ASSERT_EQ( 877 ASSERT_EQ(
875 ERROR_SUCCESS, 878 ERROR_SUCCESS,
876 key.Open(HKEY_CURRENT_USER, L"Software\\Classes\\.test1", KEY_READ)); 879 key.Open(HKEY_CURRENT_USER, L"Software\\Classes\\.test1", KEY_READ));
877 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value)); 880 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"", &value));
878 EXPECT_EQ(L"TestApp", value); 881 EXPECT_EQ(L"TestApp", value);
879 ASSERT_EQ(ERROR_SUCCESS, 882 ASSERT_EQ(ERROR_SUCCESS,
880 key.Open(HKEY_CURRENT_USER, 883 key.Open(HKEY_CURRENT_USER,
881 L"Software\\Classes\\.test1\\OpenWithProgids", 884 L"Software\\Classes\\.test1\\OpenWithProgids",
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 1003
1001 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", 1004 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ",
1002 L"MZXW6YTB", L"MZXW6YTBOI"}; 1005 L"MZXW6YTB", L"MZXW6YTBOI"};
1003 1006
1004 // Run the tests, with one more letter in the input every pass. 1007 // Run the tests, with one more letter in the input every pass.
1005 for (int i = 0; i < arraysize(expected); ++i) { 1008 for (int i = 0; i < arraysize(expected); ++i) {
1006 ASSERT_EQ(expected[i], 1009 ASSERT_EQ(expected[i],
1007 ShellUtil::ByteArrayToBase32(test_array, i)); 1010 ShellUtil::ByteArrayToBase32(test_array, i));
1008 } 1011 }
1009 } 1012 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698