OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/scoped_temp_dir.h" | |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/test/test_file_util.h" | 19 #include "base/test/test_file_util.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
23 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 23 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/debugger/devtools_window.h" | 25 #include "chrome/browser/debugger/devtools_window.h" |
26 #include "chrome/browser/download/download_prefs.h" | 26 #include "chrome/browser/download/download_prefs.h" |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1036 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
1037 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); | 1037 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); |
1038 } | 1038 } |
1039 | 1039 |
1040 // This policy isn't available on Chrome OS. | 1040 // This policy isn't available on Chrome OS. |
1041 #if !defined(OS_CHROMEOS) | 1041 #if !defined(OS_CHROMEOS) |
1042 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { | 1042 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { |
1043 // Verifies that the download directory can be forced by policy. | 1043 // Verifies that the download directory can be forced by policy. |
1044 | 1044 |
1045 // Set the initial download directory. | 1045 // Set the initial download directory. |
1046 ScopedTempDir initial_dir; | 1046 base::ScopedTempDir initial_dir; |
1047 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); | 1047 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); |
1048 browser()->profile()->GetPrefs()->SetFilePath( | 1048 browser()->profile()->GetPrefs()->SetFilePath( |
1049 prefs::kDownloadDefaultDirectory, initial_dir.path()); | 1049 prefs::kDownloadDefaultDirectory, initial_dir.path()); |
1050 // Don't prompt for the download location during this test. | 1050 // Don't prompt for the download location during this test. |
1051 browser()->profile()->GetPrefs()->SetBoolean( | 1051 browser()->profile()->GetPrefs()->SetBoolean( |
1052 prefs::kPromptForDownload, false); | 1052 prefs::kPromptForDownload, false); |
1053 | 1053 |
1054 // Verify that downloads end up on the default directory. | 1054 // Verify that downloads end up on the default directory. |
1055 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1055 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1056 DownloadAndVerifyFile(browser(), initial_dir.path(), file); | 1056 DownloadAndVerifyFile(browser(), initial_dir.path(), file); |
1057 file_util::DieFileDie(initial_dir.path().Append(file), false); | 1057 file_util::DieFileDie(initial_dir.path().Append(file), false); |
1058 | 1058 |
1059 // Override the download directory with the policy and verify a download. | 1059 // Override the download directory with the policy and verify a download. |
1060 ScopedTempDir forced_dir; | 1060 base::ScopedTempDir forced_dir; |
1061 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); | 1061 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); |
1062 PolicyMap policies; | 1062 PolicyMap policies; |
1063 policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, | 1063 policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, |
1064 POLICY_SCOPE_USER, | 1064 POLICY_SCOPE_USER, |
1065 base::Value::CreateStringValue(forced_dir.path().value())); | 1065 base::Value::CreateStringValue(forced_dir.path().value())); |
1066 provider_.UpdateChromePolicy(policies); | 1066 provider_.UpdateChromePolicy(policies); |
1067 DownloadAndVerifyFile(browser(), forced_dir.path(), file); | 1067 DownloadAndVerifyFile(browser(), forced_dir.path(), file); |
1068 // Verify that the first download location wasn't affected. | 1068 // Verify that the first download location wasn't affected. |
1069 EXPECT_FALSE(file_util::PathExists(initial_dir.path().Append(file))); | 1069 EXPECT_FALSE(file_util::PathExists(initial_dir.path().Append(file))); |
1070 } | 1070 } |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); | 1661 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); |
1662 // HomepageLocation has policy ID 1. | 1662 // HomepageLocation has policy ID 1. |
1663 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); | 1663 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); |
1664 // ShowHomeButton has policy ID 35. | 1664 // ShowHomeButton has policy ID 35. |
1665 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); | 1665 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); |
1666 // BookmarkBarEnabled has policy ID 82. | 1666 // BookmarkBarEnabled has policy ID 82. |
1667 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); | 1667 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); |
1668 } | 1668 } |
1669 | 1669 |
1670 } // namespace policy | 1670 } // namespace policy |
OLD | NEW |