This source file includes following definitions.
- TEST_F
- TEST_F
- TEST_F
#include "components/translate/core/common/translate_util.h"
#include "base/command_line.h"
#include "components/translate/core/common/translate_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
typedef testing::Test TranslateUtilTest;
TEST_F(TranslateUtilTest, ToTranslateLanguageSynonym) {
std::string language;
language = std::string("nb");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("no", language);
language = std::string("he");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("iw", language);
language = std::string("jv");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("jw", language);
language = std::string("fil");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("tl", language);
language = std::string("he-IL");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("iw-IL", language);
language = std::string("nb-NO");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("nb-NO", language);
language = std::string("en");
translate::ToTranslateLanguageSynonym(&language);
EXPECT_EQ("en", language);
}
TEST_F(TranslateUtilTest, ToChromeLanguageSynonym) {
std::string language;
language = std::string("no");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("nb", language);
language = std::string("iw");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("he", language);
language = std::string("jw");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("jv", language);
language = std::string("tl");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("fil", language);
language = std::string("iw-IL");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("he-IL", language);
language = std::string("no-NO");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("no-NO", language);
language = std::string("en");
translate::ToChromeLanguageSynonym(&language);
EXPECT_EQ("en", language);
}
TEST_F(TranslateUtilTest, SecurityOrigin) {
GURL origin = translate::GetTranslateSecurityOrigin();
EXPECT_EQ(std::string(translate::kSecurityOrigin), origin.spec());
const std::string running_origin("http://www.tamurayukari.com/");
CommandLine* command_line = CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII(translate::switches::kTranslateSecurityOrigin,
running_origin);
GURL modified_origin = translate::GetTranslateSecurityOrigin();
EXPECT_EQ(running_origin, modified_origin.spec());
}