<commit_before>// Copyright (c) 2009 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 "app/gfx/codec/jpeg_codec.h"
#include "base/file_util.h"
#include "base/shared_memory.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/test/render_view_test.h"
#include "net/base/net_errors.h"
#include "printing/image.h"
#include "printing/native_metafile.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"

using WebKit::WebCompositionCommand;
using WebKit::WebFrame;
using WebKit::WebString;
using WebKit::WebTextDirection;
using WebKit::WebURLError;

namespace {

static WebCompositionCommand ToCompositionCommand(int string_type) {
  switch (string_type) {
    default:
      NOTREACHED();
    case -1:
      return WebKit::WebCompositionCommandDiscard;
    case 0:
      return WebKit::WebCompositionCommandSet;
    case 1:
      return WebKit::WebCompositionCommandConfirm;
  }
}

}  // namespace

TEST_F(RenderViewTest, OnLoadAlternateHTMLText) {
  // Test a new navigation.
  GURL test_url("http://www.google.com/some_test_url");
  view_->OnLoadAlternateHTMLText("<html></html>", true, test_url,
                                 std::string());

  // We should have gotten two different types of start messages in the
  // following order.
  ASSERT_EQ((size_t)2, render_thread_.sink().message_count());
  const IPC::Message* msg = render_thread_.sink().GetMessageAt(0);
  EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type());

  msg = render_thread_.sink().GetMessageAt(1);<commit_msg>Remove unnecessary anonymous namespace according to agl's suggestion.<commit_after>// Copyright (c) 2009 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 "app/gfx/codec/jpeg_codec.h"
#include "base/file_util.h"
#include "base/shared_memory.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/test/render_view_test.h"
#include "net/base/net_errors.h"
#include "printing/image.h"
#include "printing/native_metafile.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"

using WebKit::WebCompositionCommand;
using WebKit::WebFrame;
using WebKit::WebString;
using WebKit::WebTextDirection;
using WebKit::WebURLError;

static WebCompositionCommand ToCompositionCommand(int string_type) {
  switch (string_type) {
    default:
      NOTREACHED();
    case -1:
      return WebKit::WebCompositionCommandDiscard;
    case 0:
      return WebKit::WebCompositionCommandSet;
    case 1:
      return WebKit::WebCompositionCommandConfirm;
  }
}

TEST_F(RenderViewTest, OnLoadAlternateHTMLText) {
  // Test a new navigation.
  GURL test_url("http://www.google.com/some_test_url");
  view_->OnLoadAlternateHTMLText("<html></html>", true, test_url,
                                 std::string());

  // We should have gotten two different types of start messages in the
  // following order.
  ASSERT_EQ((size_t)2, render_thread_.sink().message_count());
  const IPC::Message* msg = render_thread_.sink().GetMessageAt(0);
  EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type());

  msg = render_thread_.sink().GetMessageAt(1);
{'fraction_non_alphanumeric': 0.12130801687763713, 'fraction_numerical': 0.005274261603375527, 'mean_word_length': 4.844375963020031, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3855244', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1227, 'n_words': 254}