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 <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 Loading... | |
31 #include "chrome/browser/chromeos/login/user_manager.h" | 31 #include "chrome/browser/chromeos/login/user_manager.h" |
32 #include "chrome/browser/chromeos/settings/cros_settings.h" | 32 #include "chrome/browser/chromeos/settings/cros_settings.h" |
33 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 33 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
34 #include "chromeos/chromeos_switches.h" | 34 #include "chromeos/chromeos_switches.h" |
35 #endif | 35 #endif |
36 | 36 |
37 namespace extensions { | 37 namespace extensions { |
38 | 38 |
39 class ActivityDatabaseTest : public ChromeRenderViewHostTestHarness { | 39 class ActivityDatabaseTest : public ChromeRenderViewHostTestHarness { |
40 public: | 40 public: |
41 ActivityDatabaseTest() | |
42 : ui_thread_(BrowserThread::UI, MessageLoop::current()), | |
43 db_thread_(BrowserThread::DB, MessageLoop::current()), | |
44 file_thread_(BrowserThread::FILE, MessageLoop::current()) {} | |
45 | |
46 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
47 ChromeRenderViewHostTestHarness::SetUp(); | 42 ChromeRenderViewHostTestHarness::SetUp(); |
43 #if defined OS_CHROMEOS | |
44 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); | |
Jeffrey Yasskin
2013/05/27 03:12:13
I don't like having to move value objects into sco
awong
2013/05/30 21:46:09
Yeah. All choices are bad.
(1) We can't move all
| |
45 #endif | |
48 CommandLine command_line(CommandLine::NO_PROGRAM); | 46 CommandLine command_line(CommandLine::NO_PROGRAM); |
49 profile_ = | 47 profile_ = |
50 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 48 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
51 extension_service_ = static_cast<TestExtensionSystem*>( | 49 extension_service_ = static_cast<TestExtensionSystem*>( |
52 ExtensionSystem::Get(profile_))->CreateExtensionService( | 50 ExtensionSystem::Get(profile_))->CreateExtensionService( |
53 &command_line, base::FilePath(), false); | 51 &command_line, base::FilePath(), false); |
54 CommandLine::ForCurrentProcess()->AppendSwitch( | 52 CommandLine::ForCurrentProcess()->AppendSwitch( |
55 switches::kEnableExtensionActivityLogTesting); | 53 switches::kEnableExtensionActivityLogTesting); |
56 } | 54 } |
57 | 55 |
58 virtual ~ActivityDatabaseTest() { | 56 virtual void TearDown() OVERRIDE { |
59 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 57 #if defined OS_CHROMEOS |
60 MessageLoop::current()->Run(); | 58 test_user_manager_.reset(); |
59 #endif | |
60 ChromeRenderViewHostTestHarness::TearDown(); | |
61 } | 61 } |
62 | 62 |
63 protected: | 63 protected: |
64 ExtensionService* extension_service_; | 64 ExtensionService* extension_service_; |
65 Profile* profile_; | 65 Profile* profile_; |
66 | 66 |
67 private: | 67 private: |
68 content::TestBrowserThread ui_thread_; | |
69 content::TestBrowserThread db_thread_; | |
70 content::TestBrowserThread file_thread_; | |
71 | |
72 #if defined OS_CHROMEOS | 68 #if defined OS_CHROMEOS |
73 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; | 69 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; |
74 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 70 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
75 chromeos::ScopedTestCrosSettings test_cros_settings_; | 71 chromeos::ScopedTestCrosSettings test_cros_settings_; |
76 chromeos::ScopedTestUserManager test_user_manager_; | 72 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
77 #endif | 73 #endif |
78 | 74 |
79 }; | 75 }; |
80 | 76 |
81 | 77 |
82 // Check that the database is initialized properly. | 78 // Check that the database is initialized properly. |
83 TEST_F(ActivityDatabaseTest, Init) { | 79 TEST_F(ActivityDatabaseTest, Init) { |
84 base::ScopedTempDir temp_dir; | 80 base::ScopedTempDir temp_dir; |
85 base::FilePath db_file; | 81 base::FilePath db_file; |
86 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 82 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 APIAction::CALL, | 391 APIAction::CALL, |
396 "brewster", | 392 "brewster", |
397 "woooof", | 393 "woooof", |
398 "extra"); | 394 "extra"); |
399 activity_db->RecordAction(action); | 395 activity_db->RecordAction(action); |
400 activity_db->Close(); | 396 activity_db->Close(); |
401 } | 397 } |
402 | 398 |
403 } // namespace | 399 } // namespace |
404 | 400 |
OLD | NEW |