Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <vector> | |
| 6 | |
| 7 #include "chrome/browser/chrome_thread.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 #include "testing/platform_test.h" | |
| 10 | |
| 11 typedef PlatformTest ChromeThreadTest; | |
| 12 | |
| 13 TEST_F(ChromeThreadTest, Get) { | |
|
darin (slow to review)
2009/10/27 00:06:52
maybe there are still some interesting tests to wr
jam
2009/10/27 02:38:18
I couldn't think of any non-trivial tests. I figu
jam
2009/10/27 02:46:29
On second thoughts, I'll leave the file with an em
darin (slow to review)
2009/10/27 04:43:33
OK... I was thinking that you might be able to tes
| |
| 14 scoped_ptr<ChromeThread> io_thread; | |
| 15 scoped_ptr<ChromeThread> file_thread; | |
| 16 scoped_ptr<ChromeThread> db_thread; | |
| 17 | |
| 18 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::IO) == NULL); | |
| 19 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 20 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::DB) == NULL); | |
| 21 | |
| 22 // Phase 1: Create threads. | |
| 23 | |
| 24 io_thread.reset(new ChromeThread(ChromeThread::IO)); | |
| 25 file_thread.reset(new ChromeThread(ChromeThread::FILE)); | |
| 26 db_thread.reset(new ChromeThread(ChromeThread::DB)); | |
| 27 | |
| 28 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::IO) == NULL); | |
| 29 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 30 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::DB) == NULL); | |
| 31 | |
| 32 // Phase 2: Start the threads. | |
| 33 | |
| 34 io_thread->Start(); | |
| 35 file_thread->Start(); | |
| 36 db_thread->Start(); | |
| 37 | |
| 38 EXPECT_TRUE(io_thread->message_loop() != NULL); | |
| 39 EXPECT_TRUE(file_thread->message_loop() != NULL); | |
| 40 EXPECT_TRUE(db_thread->message_loop() != NULL); | |
| 41 | |
| 42 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::IO) == | |
| 43 io_thread->message_loop()); | |
| 44 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == | |
| 45 file_thread->message_loop()); | |
| 46 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::DB) == | |
| 47 db_thread->message_loop()); | |
| 48 | |
| 49 // Phase 3: Stop the threads. | |
| 50 | |
| 51 io_thread->Stop(); | |
| 52 file_thread->Stop(); | |
| 53 db_thread->Stop(); | |
| 54 | |
| 55 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::IO) == NULL); | |
| 56 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 57 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::DB) == NULL); | |
| 58 | |
| 59 // Phase 4: Destroy the threads. | |
| 60 | |
| 61 io_thread.reset(); | |
| 62 file_thread.reset(); | |
| 63 db_thread.reset(); | |
| 64 | |
| 65 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::IO) == NULL); | |
| 66 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::FILE) == NULL); | |
| 67 EXPECT_TRUE(ChromeThread::GetMessageLoop(ChromeThread::DB) == NULL); | |
| 68 } | |
| OLD | NEW |