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

Unified Diff: chrome/browser/extensions/api/messaging/native_message_process_host_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: compile fixes. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
index 080be622bcdba2286c8ab150546059550875d7a7..8b9ab0b6beded079cfe1412cf6ec7ac6a38d0161 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc
@@ -29,7 +29,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/features/feature.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
@@ -79,32 +79,26 @@ class FakeLauncher : public NativeProcessLauncher {
class NativeMessagingTest : public ::testing::Test,
public NativeMessageProcessHost::Client,
public base::SupportsWeakPtr<NativeMessagingTest> {
- public:
+ protected:
NativeMessagingTest()
: current_channel_(chrome::VersionInfo::CHANNEL_DEV),
- native_message_process_host_(NULL) {
- }
-
- virtual void SetUp() OVERRIDE {
+ native_message_process_host_(NULL),
+ thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
// Change the user data dir so native apps will be looked for in the test
// directory.
ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_));
ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, GetTestDir()));
- ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI,
- &message_loop_));
- io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO,
- &message_loop_));
}
- virtual void TearDown() OVERRIDE {
+ virtual ~NativeMessagingTest() {
// Change the user data dir back for other tests.
ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir_));
if (native_message_process_host_.get()) {
BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
native_message_process_host_.release());
}
- message_loop_.RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
virtual void PostMessageFromNativeProcess(
@@ -153,10 +147,8 @@ class NativeMessagingTest : public ::testing::Test,
Feature::ScopedCurrentChannel current_channel_;
scoped_ptr<NativeMessageProcessHost> native_message_process_host_;
base::FilePath user_data_dir_;
- base::MessageLoopForIO message_loop_;
scoped_ptr<base::RunLoop> read_message_run_loop_;
- scoped_ptr<content::TestBrowserThread> ui_thread_;
- scoped_ptr<content::TestBrowserThread> io_thread_;
+ content::TestBrowserThreadBundle thread_bundle_;
std::string last_message_;
scoped_ptr<base::DictionaryValue> last_message_parsed_;
};
@@ -195,10 +187,10 @@ TEST_F(NativeMessagingTest, SingleSendMessageWrite) {
AsWeakPtr(), kTestNativeMessagingExtensionId, "empty_app.py",
0, launcher.Pass());
ASSERT_TRUE(native_message_process_host_.get());
- message_loop_.RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
native_message_process_host_->Send(kTestMessage);
- message_loop_.RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
std::string output;
base::TimeTicks start_time = base::TimeTicks::Now();

Powered by Google App Engine
This is Rietveld 408576698