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

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

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 284 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
284 base::FilePath downloaded = dir.Append(file); 285 base::FilePath downloaded = dir.Append(file);
285 EXPECT_FALSE(file_util::PathExists(downloaded)); 286 EXPECT_FALSE(file_util::PathExists(downloaded));
286 ui_test_utils::NavigateToURLWithDisposition( 287 ui_test_utils::NavigateToURLWithDisposition(
287 browser, url, CURRENT_TAB, 288 browser, url, CURRENT_TAB,
288 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 289 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
289 observer.WaitForFinished(); 290 observer.WaitForFinished();
290 EXPECT_EQ( 291 EXPECT_EQ(
291 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE)); 292 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE));
292 EXPECT_TRUE(file_util::PathExists(downloaded)); 293 EXPECT_TRUE(file_util::PathExists(downloaded));
293 file_util::FileEnumerator enumerator( 294 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES);
294 dir, false, file_util::FileEnumerator::FILES);
295 EXPECT_EQ(file, enumerator.Next().BaseName()); 295 EXPECT_EQ(file, enumerator.Next().BaseName());
296 EXPECT_EQ(base::FilePath(), enumerator.Next()); 296 EXPECT_EQ(base::FilePath(), enumerator.Next());
297 } 297 }
298 298
299 #if defined(OS_CHROMEOS) 299 #if defined(OS_CHROMEOS)
300 int CountScreenshots() { 300 int CountScreenshots() {
301 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( 301 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
302 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); 302 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext());
303 file_util::FileEnumerator enumerator(download_prefs->DownloadPath(), 303 base::FileEnumerator enumerator(download_prefs->DownloadPath(),
304 false, file_util::FileEnumerator::FILES, 304 false, base::FileEnumerator::FILES,
305 "Screenshot*"); 305 "Screenshot*");
306 int count = 0; 306 int count = 0;
307 while (!enumerator.Next().empty()) 307 while (!enumerator.Next().empty())
308 count++; 308 count++;
309 return count; 309 return count;
310 } 310 }
311 #endif 311 #endif
312 312
313 // Checks if WebGL is enabled in the given WebContents. 313 // Checks if WebGL is enabled in the given WebContents.
314 bool IsWebGLEnabled(content::WebContents* contents) { 314 bool IsWebGLEnabled(content::WebContents* contents) {
315 bool result = false; 315 bool result = false;
(...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 chrome_variations::VariationsService::GetVariationsServerURL( 2329 chrome_variations::VariationsService::GetVariationsServerURL(
2330 g_browser_process->local_state()); 2330 g_browser_process->local_state());
2331 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); 2331 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true));
2332 std::string value; 2332 std::string value;
2333 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 2333 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
2334 EXPECT_EQ("restricted", value); 2334 EXPECT_EQ("restricted", value);
2335 } 2335 }
2336 #endif 2336 #endif
2337 2337
2338 } // namespace policy 2338 } // 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