chromium/chrome/renderer/translate/translate_script_browsertest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/cxx23_to_underlying.h"
#include "chrome/test/base/chrome_render_view_test.h"
#include "components/grit/components_resources.h"
#include "components/translate/core/common/translate_errors.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "ui/base/resource/resource_bundle.h"
#include "v8/include/v8.h"

WebScriptSource;

namespace {

// JavaScript code to set runtime test flags.
const char kThrowInitializationError[] =;
const char kThrowUnexpectedScriptError[] =;
const char kCallbackReturnBooleanError[] =;
const char kCallbackReturnNumberError[] =;
const char kSetCallbackErrorCode[] =;

// JavaScript code to check if any error happens.
const char kError[] =;

// JavaScript code to get error code.
const char kErrorCode[] =;

// JavaScript code to check if the library is ready.
const char kLibReady[] =;

// JavaScript code to perform translation.
const char kTranslate[] =;

// JavaScript code to mimic element.js provided by a translate server.
const char kElementJs[] =;

std::string GenerateSetCallbackErrorCodeScript(int code) {}

}  // namespace

// This class is for testing resource/translate.js works and reports errors
// correctly.
class TranslateScriptBrowserTest : public ChromeRenderViewTest {};

// Test if onTranslateElementLoad() succeeds to initialize the element library.
TEST_F(TranslateScriptBrowserTest, ElementLoadSuccess) {}

// Test if onTranslateElementLoad() fails to initialize the element library and
// report the right error code.
TEST_F(TranslateScriptBrowserTest, ElementLoadFailure) {}

// Test if cr.googleTranslate.translate() works.
TEST_F(TranslateScriptBrowserTest, TranslateSuccess) {}

// Test if cr.googleTranslate.translate() handles library exception correctly.
TEST_F(TranslateScriptBrowserTest, TranslateFail) {}

// Test if onTranslateProgress callback handles boolean type error correctly.
// Remove this test once server side changes the API to return a number.
TEST_F(TranslateScriptBrowserTest, CallbackGetBooleanError) {}

// Test if onTranslateProgress callback handles number type error correctly and
// converts it to the proper error code.
TEST_F(TranslateScriptBrowserTest, CallbackGetNumberError1) {}

// Test if onTranslateProgress callback handles number type error correctly and
// converts it to the proper error code.
TEST_F(TranslateScriptBrowserTest, CallbackGetNumberError2) {}

// TODO(toyoshim): Add test for onLoadJavaScript.