browser_action_apitest.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/extension_system.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/browser.h"
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that tooltips of a browser action icon can be specified using UTF8.
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See http://crbug.com/25349.
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) {
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ExtensionService* service = extensions::ExtensionSystem::Get(
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      browser()->profile())->extension_service();
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const size_t size_before = service->extensions()->size();
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        .AppendASCII("title_localized"));
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const Extension* extension = LoadExtension(extension_path);
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ASSERT_TRUE(extension);
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ASSERT_EQ(size_before + 1, service->extensions()->size());
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(),
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)               extension->description().c_str());
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(),
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)               extension->name().c_str());
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int tab_id = ExtensionTabUtil::GetTabId(
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      browser()->tab_strip_model()->GetActiveWebContents());
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(),
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)               extension->browser_action()->GetTitle(tab_id).c_str());
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
31