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 21 matching lines...) Expand all Loading... |
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() | 41 ActivityDatabaseTest() |
42 : ui_thread_(BrowserThread::UI, MessageLoop::current()), | 42 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
43 db_thread_(BrowserThread::DB, MessageLoop::current()), | 43 db_thread_(BrowserThread::DB, base::MessageLoop::current()), |
44 file_thread_(BrowserThread::FILE, MessageLoop::current()) {} | 44 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} |
45 | 45 |
46 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
47 ChromeRenderViewHostTestHarness::SetUp(); | 47 ChromeRenderViewHostTestHarness::SetUp(); |
48 CommandLine command_line(CommandLine::NO_PROGRAM); | 48 CommandLine command_line(CommandLine::NO_PROGRAM); |
49 profile_ = | 49 profile_ = |
50 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 50 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
51 extension_service_ = static_cast<TestExtensionSystem*>( | 51 extension_service_ = static_cast<TestExtensionSystem*>( |
52 ExtensionSystem::Get(profile_))->CreateExtensionService( | 52 ExtensionSystem::Get(profile_))->CreateExtensionService( |
53 &command_line, base::FilePath(), false); | 53 &command_line, base::FilePath(), false); |
54 CommandLine::ForCurrentProcess()->AppendSwitch( | 54 CommandLine::ForCurrentProcess()->AppendSwitch( |
55 switches::kEnableExtensionActivityLogTesting); | 55 switches::kEnableExtensionActivityLogTesting); |
56 } | 56 } |
57 | 57 |
58 virtual ~ActivityDatabaseTest() { | 58 virtual ~ActivityDatabaseTest() { |
59 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 59 base::MessageLoop::current()->PostTask(FROM_HERE, |
60 MessageLoop::current()->Run(); | 60 base::MessageLoop::QuitClosure()); |
| 61 base::MessageLoop::current()->Run(); |
61 } | 62 } |
62 | 63 |
63 protected: | 64 protected: |
64 ExtensionService* extension_service_; | 65 ExtensionService* extension_service_; |
65 Profile* profile_; | 66 Profile* profile_; |
66 | 67 |
67 private: | 68 private: |
68 content::TestBrowserThread ui_thread_; | 69 content::TestBrowserThread ui_thread_; |
69 content::TestBrowserThread db_thread_; | 70 content::TestBrowserThread db_thread_; |
70 content::TestBrowserThread file_thread_; | 71 content::TestBrowserThread file_thread_; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 "woof", | 365 "woof", |
365 "extra"); | 366 "extra"); |
366 activity_db->RecordAction(api_action); | 367 activity_db->RecordAction(api_action); |
367 | 368 |
368 scoped_ptr<std::vector<scoped_refptr<Action> > > actions_before = | 369 scoped_ptr<std::vector<scoped_refptr<Action> > > actions_before = |
369 activity_db->GetActions("punky", 0); | 370 activity_db->GetActions("punky", 0); |
370 ASSERT_EQ(0, static_cast<int>(actions_before->size())); | 371 ASSERT_EQ(0, static_cast<int>(actions_before->size())); |
371 | 372 |
372 // Artificially trigger and then stop the timer. | 373 // Artificially trigger and then stop the timer. |
373 activity_db->SetTimerForTesting(0); | 374 activity_db->SetTimerForTesting(0); |
374 MessageLoop::current()->RunUntilIdle(); | 375 base::MessageLoop::current()->RunUntilIdle(); |
375 | 376 |
376 scoped_ptr<std::vector<scoped_refptr<Action> > > actions_after = | 377 scoped_ptr<std::vector<scoped_refptr<Action> > > actions_after = |
377 activity_db->GetActions("punky", 0); | 378 activity_db->GetActions("punky", 0); |
378 ASSERT_EQ(1, static_cast<int>(actions_after->size())); | 379 ASSERT_EQ(1, static_cast<int>(actions_after->size())); |
379 | 380 |
380 activity_db->Close(); | 381 activity_db->Close(); |
381 } | 382 } |
382 | 383 |
383 // Check that nothing explodes if the DB isn't initialized. | 384 // Check that nothing explodes if the DB isn't initialized. |
384 TEST_F(ActivityDatabaseTest, InitFailure) { | 385 TEST_F(ActivityDatabaseTest, InitFailure) { |
(...skipping 10 matching lines...) Expand all Loading... |
395 APIAction::CALL, | 396 APIAction::CALL, |
396 "brewster", | 397 "brewster", |
397 "woooof", | 398 "woooof", |
398 "extra"); | 399 "extra"); |
399 activity_db->RecordAction(action); | 400 activity_db->RecordAction(action); |
400 activity_db->Close(); | 401 activity_db->Close(); |
401 } | 402 } |
402 | 403 |
403 } // namespace | 404 } // namespace |
404 | 405 |
OLD | NEW |