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

Side by Side Diff: chrome/browser/extensions/activity_log/activity_database_unittest.cc

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT 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 <string> 5 #include <string>
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/chromeos/login/mock_user_manager.h" 31 #include "chrome/browser/chromeos/login/mock_user_manager.h"
32 #include "chrome/browser/chromeos/login/user_manager.h" 32 #include "chrome/browser/chromeos/login/user_manager.h"
33 #include "chrome/browser/chromeos/settings/cros_settings.h" 33 #include "chrome/browser/chromeos/settings/cros_settings.h"
34 #include "chrome/browser/chromeos/settings/device_settings_service.h" 34 #include "chrome/browser/chromeos/settings/device_settings_service.h"
35 #include "chromeos/chromeos_switches.h" 35 #include "chromeos/chromeos_switches.h"
36 #endif 36 #endif
37 37
38 namespace extensions { 38 namespace extensions {
39 39
40 class ActivityDatabaseTest : public ChromeRenderViewHostTestHarness { 40 class ActivityDatabaseTest : public ChromeRenderViewHostTestHarness {
41 public: 41 protected:
42 ActivityDatabaseTest()
43 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
44 db_thread_(BrowserThread::DB, base::MessageLoop::current()),
45 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {}
46
47 virtual void SetUp() OVERRIDE { 42 virtual void SetUp() OVERRIDE {
48 ChromeRenderViewHostTestHarness::SetUp(); 43 ChromeRenderViewHostTestHarness::SetUp();
44 #if defined OS_CHROMEOS
45 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
46 #endif
49 CommandLine command_line(CommandLine::NO_PROGRAM); 47 CommandLine command_line(CommandLine::NO_PROGRAM);
50 profile_ = 48 profile_ =
51 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 49 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
52 extension_service_ = static_cast<TestExtensionSystem*>( 50 extension_service_ = static_cast<TestExtensionSystem*>(
53 ExtensionSystem::Get(profile_))->CreateExtensionService( 51 ExtensionSystem::Get(profile_))->CreateExtensionService(
54 &command_line, base::FilePath(), false); 52 &command_line, base::FilePath(), false);
55 CommandLine::ForCurrentProcess()->AppendSwitch( 53 CommandLine::ForCurrentProcess()->AppendSwitch(
56 switches::kEnableExtensionActivityLogTesting); 54 switches::kEnableExtensionActivityLogTesting);
57 } 55 }
58 56
59 virtual ~ActivityDatabaseTest() { 57 virtual void TearDown() OVERRIDE {
60 base::MessageLoop::current()->PostTask(FROM_HERE, 58 #if defined OS_CHROMEOS
61 base::MessageLoop::QuitClosure()); 59 test_user_manager_.reset();
62 base::MessageLoop::current()->Run(); 60 #endif
61 ChromeRenderViewHostTestHarness::TearDown();
63 } 62 }
64 63
65 protected: 64 protected:
66 ExtensionService* extension_service_; 65 ExtensionService* extension_service_;
67 Profile* profile_; 66 Profile* profile_;
68 67
69 private: 68 private:
70 content::TestBrowserThread ui_thread_;
71 content::TestBrowserThread db_thread_;
72 content::TestBrowserThread file_thread_;
73
74 #if defined OS_CHROMEOS 69 #if defined OS_CHROMEOS
75 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; 70 chromeos::ScopedStubCrosEnabler stub_cros_enabler_;
76 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 71 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
77 chromeos::ScopedTestCrosSettings test_cros_settings_; 72 chromeos::ScopedTestCrosSettings test_cros_settings_;
78 chromeos::ScopedTestUserManager test_user_manager_; 73 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
79 #endif 74 #endif
80 75
81 }; 76 };
82 77
83 78
84 // Check that the database is initialized properly. 79 // Check that the database is initialized properly.
85 TEST_F(ActivityDatabaseTest, Init) { 80 TEST_F(ActivityDatabaseTest, Init) {
86 base::ScopedTempDir temp_dir; 81 base::ScopedTempDir temp_dir;
87 base::FilePath db_file; 82 base::FilePath db_file;
88 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 83 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 APIAction::CALL, 392 APIAction::CALL,
398 "brewster", 393 "brewster",
399 "woooof", 394 "woooof",
400 "extra"); 395 "extra");
401 activity_db->RecordAction(action); 396 activity_db->RecordAction(action);
402 activity_db->Close(); 397 activity_db->Close();
403 } 398 }
404 399
405 } // namespace 400 } // namespace
406 401
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_tab_unittest.cc ('k') | chrome/browser/extensions/activity_log/activity_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698