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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 271533004: Turning on MultiProfile by default for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 // This test creates a safebrowsing service using test safebrowsing database 5 // This test creates a safebrowsing service using test safebrowsing database
6 // and a test protocol manager. It is used to test logics in safebrowsing 6 // and a test protocol manager. It is used to test logics in safebrowsing
7 // service. 7 // service.
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.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/metrics/field_trial.h" 16 #include "base/metrics/field_trial.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/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/test/thread_test_helper.h" 20 #include "base/test/thread_test_helper.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/prerender/prerender_manager.h" 24 #include "chrome/browser/prerender/prerender_manager.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/profiles/startup_task_runner_service.h" 27 #include "chrome/browser/profiles/startup_task_runner_service.h"
27 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" 28 #include "chrome/browser/profiles/startup_task_runner_service_factory.h"
28 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 29 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
29 #include "chrome/browser/safe_browsing/database_manager.h" 30 #include "chrome/browser/safe_browsing/database_manager.h"
30 #include "chrome/browser/safe_browsing/protocol_manager.h" 31 #include "chrome/browser/safe_browsing/protocol_manager.h"
31 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 32 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
33 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 34 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
34 #include "chrome/browser/safe_browsing/ui_manager.h" 35 #include "chrome/browser/safe_browsing/ui_manager.h"
35 #include "chrome/browser/ui/browser.h" 36 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" 37 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/common/chrome_paths.h" 38 #include "chrome/common/chrome_paths.h"
39 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
39 #include "chrome/test/base/in_process_browser_test.h" 41 #include "chrome/test/base/in_process_browser_test.h"
40 #include "chrome/test/base/ui_test_utils.h" 42 #include "chrome/test/base/ui_test_utils.h"
41 #include "content/public/browser/web_contents.h" 43 #include "content/public/browser/web_contents.h"
42 #include "net/cookies/cookie_store.h" 44 #include "net/cookies/cookie_store.h"
43 #include "sql/connection.h" 45 #include "sql/connection.h"
44 #include "sql/statement.h" 46 #include "sql/statement.h"
45 #include "testing/gmock/include/gmock/gmock.h" 47 #include "testing/gmock/include/gmock/gmock.h"
46 48
49 #if defined(OS_CHROMEOS)
50 #include "chromeos/chromeos_switches.h"
51 #endif
52
47 using content::BrowserThread; 53 using content::BrowserThread;
48 using content::InterstitialPage; 54 using content::InterstitialPage;
49 using content::WebContents; 55 using content::WebContents;
50 using ::testing::_; 56 using ::testing::_;
51 using ::testing::Mock; 57 using ::testing::Mock;
52 using ::testing::StrictMock; 58 using ::testing::StrictMock;
53 59
54 namespace { 60 namespace {
55 61
56 void InvokeFullHashCallback( 62 void InvokeFullHashCallback(
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 virtual void TearDown() { 397 virtual void TearDown() {
392 InProcessBrowserTest::TearDown(); 398 InProcessBrowserTest::TearDown();
393 399
394 // Unregister test factories after InProcessBrowserTest::TearDown 400 // Unregister test factories after InProcessBrowserTest::TearDown
395 // (which destructs SafeBrowsingService). 401 // (which destructs SafeBrowsingService).
396 SafeBrowsingDatabase::RegisterFactory(NULL); 402 SafeBrowsingDatabase::RegisterFactory(NULL);
397 SafeBrowsingProtocolManager::RegisterFactory(NULL); 403 SafeBrowsingProtocolManager::RegisterFactory(NULL);
398 SafeBrowsingService::RegisterFactory(NULL); 404 SafeBrowsingService::RegisterFactory(NULL);
399 } 405 }
400 406
407 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
408 // Makes sure the auto update is not triggered during the test.
409 // This test will fill up the database using testing prefixes
410 // and urls.
411 command_line->AppendSwitch(switches::kSbDisableAutoUpdate);
412 #if defined(OS_CHROMEOS)
413 command_line->AppendSwitch(
414 chromeos::switches::kIgnoreUserProfileMappingForTests);
415 #endif
416 }
417
401 virtual void SetUpInProcessBrowserTestFixture() { 418 virtual void SetUpInProcessBrowserTestFixture() {
402 ASSERT_TRUE(test_server()->Start()); 419 ASSERT_TRUE(test_server()->Start());
403 } 420 }
404 421
405 // This will setup the "url" prefix in database and prepare protocol manager 422 // This will setup the "url" prefix in database and prepare protocol manager
406 // to response with |full_hash| for get full hash request. 423 // to response with |full_hash| for get full hash request.
407 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) { 424 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) {
408 std::vector<SBPrefix> prefix_hits; 425 std::vector<SBPrefix> prefix_hits;
409 prefix_hits.push_back(full_hash.hash.prefix); 426 prefix_hits.push_back(full_hash.hash.prefix);
410 427
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 content::WindowedNotificationObserver observer( 1011 content::WindowedNotificationObserver observer(
995 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 1012 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
996 content::Source<SafeBrowsingDatabaseManager>( 1013 content::Source<SafeBrowsingDatabaseManager>(
997 sb_service_->database_manager().get())); 1014 sb_service_->database_manager().get()));
998 BrowserThread::PostTask( 1015 BrowserThread::PostTask(
999 BrowserThread::IO, 1016 BrowserThread::IO,
1000 FROM_HERE, 1017 FROM_HERE,
1001 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); 1018 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this));
1002 observer.Wait(); 1019 observer.Wait();
1003 } 1020 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698