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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 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 | Annotate | Revision Log
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 <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_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_enumerator.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/path_service.h" 17 #include "base/path_service.h"
17 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
18 #include "base/run_loop.h" 19 #include "base/run_loop.h"
19 #include "base/string16.h" 20 #include "base/string16.h"
20 #include "base/string_util.h" 21 #include "base/string_util.h"
21 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
22 #include "base/test/test_file_util.h" 23 #include "base/test/test_file_util.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 271 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
271 base::FilePath downloaded = dir.Append(file); 272 base::FilePath downloaded = dir.Append(file);
272 EXPECT_FALSE(file_util::PathExists(downloaded)); 273 EXPECT_FALSE(file_util::PathExists(downloaded));
273 ui_test_utils::NavigateToURLWithDisposition( 274 ui_test_utils::NavigateToURLWithDisposition(
274 browser, url, CURRENT_TAB, 275 browser, url, CURRENT_TAB,
275 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 276 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
276 observer.WaitForFinished(); 277 observer.WaitForFinished();
277 EXPECT_EQ( 278 EXPECT_EQ(
278 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE)); 279 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE));
279 EXPECT_TRUE(file_util::PathExists(downloaded)); 280 EXPECT_TRUE(file_util::PathExists(downloaded));
280 file_util::FileEnumerator enumerator( 281 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES);
281 dir, false, file_util::FileEnumerator::FILES);
282 EXPECT_EQ(file, enumerator.Next().BaseName()); 282 EXPECT_EQ(file, enumerator.Next().BaseName());
283 EXPECT_EQ(base::FilePath(), enumerator.Next()); 283 EXPECT_EQ(base::FilePath(), enumerator.Next());
284 } 284 }
285 285
286 #if defined(OS_CHROMEOS) 286 #if defined(OS_CHROMEOS)
287 int CountScreenshots() { 287 int CountScreenshots() {
288 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( 288 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
289 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); 289 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext());
290 file_util::FileEnumerator enumerator(download_prefs->DownloadPath(), 290 base::FileEnumerator enumerator(download_prefs->DownloadPath(),
291 false, file_util::FileEnumerator::FILES, 291 false, base::FileEnumerator::FILES,
292 "Screenshot*"); 292 "Screenshot*");
293 int count = 0; 293 int count = 0;
294 while (!enumerator.Next().empty()) 294 while (!enumerator.Next().empty())
295 count++; 295 count++;
296 return count; 296 return count;
297 } 297 }
298 #endif 298 #endif
299 299
300 // Checks if WebGL is enabled in the given WebContents. 300 // Checks if WebGL is enabled in the given WebContents.
301 bool IsWebGLEnabled(content::WebContents* contents) { 301 bool IsWebGLEnabled(content::WebContents* contents) {
302 bool result = false; 302 bool result = false;
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 chrome_variations::VariationsService::GetVariationsServerURL( 2082 chrome_variations::VariationsService::GetVariationsServerURL(
2083 g_browser_process->local_state()); 2083 g_browser_process->local_state());
2084 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); 2084 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true));
2085 std::string value; 2085 std::string value;
2086 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 2086 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
2087 EXPECT_EQ("restricted", value); 2087 EXPECT_EQ("restricted", value);
2088 } 2088 }
2089 #endif 2089 #endif
2090 2090
2091 } // namespace policy 2091 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/config_dir_policy_loader.cc ('k') | chrome/browser/printing/printing_layout_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698