forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce InputMethodEngineIBusBrowserTest.
This is first CL to add browser tests for Extension IME. I will add more tests if this is granted. BUG=179912 TEST=ran browser_tests --gtest_filter=InputMethodEngine* Review URL: https://chromiumcodereview.appspot.com/13779004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193664 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
nona@chromium.org
committed
Apr 11, 2013
1 parent
34032d8
commit ee7b0d1
Showing
4 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) 2012 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 "chrome/browser/extensions/extension_browsertest.h" | ||
#include "chromeos/dbus/dbus_thread_manager.h" | ||
#include "chromeos/dbus/ibus/mock_ibus_client.h" | ||
#include "chromeos/dbus/mock_dbus_thread_manager.h" | ||
#include "chromeos/dbus/mock_update_engine_client.h" | ||
#include "dbus/mock_bus.h" | ||
|
||
// TODO(nona): Remove gmock dependency once crbug.com/223061 is fixed. | ||
#include "testing/gmock/include/gmock/gmock.h" | ||
|
||
using testing::Return; | ||
using testing::_; | ||
|
||
namespace chromeos { | ||
namespace { | ||
|
||
// InputMethod extension should work on 1)normal extension, 2)normal extension | ||
// in incognito mode 3)component extension. | ||
enum TestType { | ||
kTestTypeNormal = 0, | ||
kTestTypeIncognito = 1, | ||
kTestTypeComponent = 2, | ||
}; | ||
|
||
class InputMethodEngineIBusBrowserTest | ||
: public ExtensionBrowserTest, | ||
public ::testing::WithParamInterface<TestType> { | ||
public: | ||
InputMethodEngineIBusBrowserTest() | ||
: ExtensionBrowserTest(), | ||
mock_dbus_thread_manager_(NULL) {} | ||
virtual ~InputMethodEngineIBusBrowserTest() {} | ||
|
||
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | ||
mock_dbus_thread_manager_ = new MockDBusThreadManager(); | ||
DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager_); | ||
ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | ||
|
||
// Necessary for launching browser tests with MockDBusThreadManager. | ||
// TODO(nona): Remove this once crbug.com/223061 is fixed. | ||
EXPECT_CALL(*mock_dbus_thread_manager_->mock_update_engine_client(), | ||
GetLastStatus()) | ||
.Times(1) | ||
.WillOnce(Return(chromeos::MockUpdateEngineClient::Status())); | ||
|
||
// TODO(nona): Remove this once crbug.com/223061 is fixed. | ||
EXPECT_CALL(*mock_dbus_thread_manager_, InitIBusBus(_, _)) | ||
.WillOnce(Invoke(this, | ||
&InputMethodEngineIBusBrowserTest::OnInitIBusBus)); | ||
} | ||
|
||
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | ||
DBusThreadManager::Shutdown(); | ||
} | ||
|
||
protected: | ||
bool LoadExtensionWithType(const std::string& extension_name, | ||
TestType type) { | ||
switch (type) { | ||
case kTestTypeNormal: | ||
return LoadExtension(test_data_dir_.AppendASCII(extension_name)); | ||
case kTestTypeIncognito: | ||
return LoadExtensionIncognito( | ||
test_data_dir_.AppendASCII(extension_name)); | ||
case kTestTypeComponent: | ||
return LoadExtensionAsComponent( | ||
test_data_dir_.AppendASCII(extension_name)); | ||
} | ||
NOTREACHED(); | ||
return false; | ||
} | ||
|
||
void OnInitIBusBus(const std::string& ibus_address, | ||
const base::Closure& closure) { | ||
dbus::Bus::Options options; | ||
mock_bus_ = new dbus::MockBus(options); | ||
EXPECT_CALL(*mock_dbus_thread_manager_, GetIBusBus()) | ||
.WillRepeatedly(Return(mock_bus_)); | ||
} | ||
|
||
MockDBusThreadManager* mock_dbus_thread_manager_; | ||
scoped_refptr<dbus::MockBus> mock_bus_; | ||
}; | ||
|
||
INSTANTIATE_TEST_CASE_P(InputMethodEngineIBusBrowserTest, | ||
InputMethodEngineIBusBrowserTest, | ||
::testing::Values(kTestTypeNormal)); | ||
INSTANTIATE_TEST_CASE_P(InputMethodEngineIBusIncognitoBrowserTest, | ||
InputMethodEngineIBusBrowserTest, | ||
::testing::Values(kTestTypeIncognito)); | ||
INSTANTIATE_TEST_CASE_P(InputMethodEngineIBusComponentExtensionBrowserTest, | ||
InputMethodEngineIBusBrowserTest, | ||
::testing::Values(kTestTypeComponent)); | ||
|
||
IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest, | ||
RegisterComponentTest) { | ||
MockIBusClient* ibus_client = mock_dbus_thread_manager_->mock_ibus_client(); | ||
// This will load "chrome/test/data/extensions/input_ime" | ||
ASSERT_TRUE(LoadExtensionWithType("input_ime", GetParam())); | ||
// The reason why not EXPECT_EQ is that extension will be reloaded in the | ||
// case of incognito mode switching. Thus registeration will be happend | ||
// multiple times. Calling at least once is sufficient for IBus component. | ||
EXPECT_LE(1, ibus_client->register_component_call_count()); | ||
} | ||
|
||
} // namespace | ||
} // namespace chromeos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChrRrvYxe938GqNtcvN9Y910JLccbU+1Q6yCcOrtDAmAgdR4rtEGfF/j0FtqhBD7DG3Y7/v9hy/VJ9lk2TTbeT+OhNXAEG1LL2AbD4KX9U8J8o1k2iqt3CM0YUN/7Hzv2UkWq4pxa89IzV0oENzZS63/iz4asD+PakyU8t+BSX4wIDAQAB", | ||
"name": "Sample Input Method For Testing", | ||
"version": "0.1", | ||
"manifest_version": 2, | ||
"description": "Sample Input Method For Testing", | ||
"permissions": [ "input" ], | ||
"input_components": [{ | ||
"name": "test ime", | ||
"type": "ime", | ||
"id": "test-ime", | ||
"description": "A input method for testing.", | ||
"language": "en", | ||
"layouts": ["us::eng"] | ||
}] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters