<commit_before>// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/waitable_event.h"
#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/mock_render_process.h"
#include "chrome/renderer/render_thread.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

const char kThreadName[] = "render_thread_unittest";

class RenderThreadTest : public testing::Test {
 public:
  virtual void SetUp() {
    // Need a MODE_SERVER to make MODE_CLIENTs (like a RenderThread) happy.
    channel_ = new IPC::Channel(kThreadName, IPC::Channel::MODE_SERVER, NULL);
    mock_process_.reset(new MockProcess());
    mock_process_->set_main_thread(new RenderThread(kThreadName));
  }

  virtual void TearDown() {
    message_loop_.RunAllPending();
    mock_process_.reset();
    // Need to fully destruct IPC::SyncChannel before the message loop goes
    // away.
    message_loop_.RunAllPending();
    // Delete the server channel after the RenderThread so that
    // IPC::SyncChannel's OnChannelError doesn't fire on the context and attempt
    // to use the listener thread which is now gone.
    delete channel_;
  }

 protected:
  MessageLoop message_loop_;
  scoped_ptr<MockProcess> mock_process_;
  IPC::Channel *channel_;
};

TEST_F(RenderThreadTest, TestGlobal) {
  ASSERT_TRUE(RenderThread::current());
}

TEST_F(RenderThreadTest, TestVisitedMsg) {
#if defined(OS_WIN)<commit_msg>Disable RenderThread unittests. They're causing the unit tests to not complete.<commit_after>// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/waitable_event.h"
#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/mock_render_process.h"
#include "chrome/renderer/render_thread.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

const char kThreadName[] = "render_thread_unittest";

class RenderThreadTest : public testing::Test {
 public:
  virtual void SetUp() {
    // Need a MODE_SERVER to make MODE_CLIENTs (like a RenderThread) happy.
    channel_ = new IPC::Channel(kThreadName, IPC::Channel::MODE_SERVER, NULL);
    mock_process_.reset(new MockProcess());
    mock_process_->set_main_thread(new RenderThread(kThreadName));
  }

  virtual void TearDown() {
    message_loop_.RunAllPending();
    mock_process_.reset();
    // Need to fully destruct IPC::SyncChannel before the message loop goes
    // away.
    message_loop_.RunAllPending();
    // Delete the server channel after the RenderThread so that
    // IPC::SyncChannel's OnChannelError doesn't fire on the context and attempt
    // to use the listener thread which is now gone.
    delete channel_;
  }

 protected:
  MessageLoop message_loop_;
  scoped_ptr<MockProcess> mock_process_;
  IPC::Channel *channel_;
};

TEST_F(RenderThreadTest, DISABLED_TestGlobal) {
  ASSERT_TRUE(RenderThread::current());
}

TEST_F(RenderThreadTest, DISABLED_TestVisitedMsg) {
#if defined(OS_WIN)
{'fraction_non_alphanumeric': 0.10198388096714198, 'fraction_numerical': 0.0024798512089274642, 'mean_word_length': 4.631762652705061, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3300509', 'n_tokens_mistral': 989, 'n_tokens_neox': 987, 'n_words': 275}