Refactoring Input method menu is not offscreen

Change-Id: Iff83160eb6c99d6109098e431341240a21274665
This commit is contained in:
Niklas Laxström
2013-10-30 12:13:51 +02:00
committed by Amir E. Aharoni
parent 135d1bc2b7
commit 967683c98e
5 changed files with 47 additions and 56 deletions

View File

@@ -52,31 +52,15 @@ input method.
Then I should see the input method indicator
And in it there must be an element with Malayalam text
@login @reset-preferences-after
Scenario: Input method menu is not offscreen
Input method indicator is not offscreen for English and RTL languages.
Given I am logged in
Given I set "English" as the interface language
When I visit page in Vector skin
And I open the input method menu
@commons.wikimedia.beta.wmflabs.org
Scenario Outline: Input method menu is completely visible
Given I visit a random page with <skin> skin and <language> as the interface language
When I open the input method menu
Then I should see the input method menu is not offscreen
Given I am logged in
Given I set "Hebrew" as the interface language
When I visit page in Monobook skin
And I open the input method menu
Then I should see the input method menu is not offscreen
Given I am logged in
Given I set "English" as the interface language
When I visit page in Monobook skin
And I open the input method menu
Then I should see the input method menu is not offscreen
Given I am logged in
Given I set "Hebrew" as the interface language
When I visit page in Vector skin
And I open the input method menu
Then I should see the input method menu is not offscreen
Examples:
| skin | language |
| Vector | English |
| Vector | Hebrew |
| Monobook | English |
#| Monobook | Hebrew |

View File

@@ -63,20 +63,10 @@ Then(/^in it there must be an element with Malayalam text$/) do
on(IMEPage).input_method_enabled_element.text.should == 'ഇൻസ്ക്രിപ്റ്റ് 2'
end
When(/^I visit page in Vector skin$/) do
visit(PanelPage, :using_params => {:extra => "useskin=vector"})
end
When(/^I visit page in Monobook skin$/) do
visit(PanelPage, :using_params => {:extra => "useskin=monobook"})
Given(/^I visit a random page with (.+) skin and (.+) as the interface language$/) do |skin, language|
visit(IMEPage, :using_params => {:extra => "useskin=#{skin.downcase}&uselang=#{on(IMEPage).language_to_code(language)}"})
end
Then(/^I should see the input method menu is not offscreen$/) do
@browser.execute_script( "
var $selectorMenu = $( '.imeselector-menu' ),
menuLeft = $selectorMenu.offset().left,
menuRight = menuLeft + $selectorMenu.width();
return ( menuLeft >= 0 && menuRight <= $( window ).width() );
" ).should == true
on(IMEPage).ime_input_method_menu_onscreen?.should == true
end

View File

@@ -0,0 +1,20 @@
module LanguageModule
include PageObject
def language_to_code(language)
case language
when 'German'
'de'
when 'English'
'en'
when 'Finnish'
'fi'
when 'Hebrew'
'he'
when 'Hindi'
'hi'
else
pending
end
end
end

View File

@@ -1,5 +1,9 @@
class IMEPage
include PageObject
include LanguageModule
include URL
page_url URL.url('?<%=params[:extra]%>')
div(:input_method, class: 'imeselector imeselector-toggle')
a(:input_method_enabled, class: 'ime-name imeselector-toggle')
@@ -10,4 +14,13 @@ class IMEPage
li(:malayalam_inscript2, data_ime_inputmethod: 'ml-inscript2')
a(:more_languages, class: 'ime-selector-more-languages')
text_field(:search_input, id: 'searchInput')
def ime_input_method_menu_onscreen?
@browser.execute_script( "
var $selectorMenu = $( '.imeselector-menu' ),
menuLeft = $selectorMenu.offset().left,
menuRight = menuLeft + $selectorMenu.width();
return ( menuLeft >= 0 && menuRight <= $( window ).width() );" )
end
end

View File

@@ -1,5 +1,6 @@
class PanelPage
include PageObject
include LanguageModule
include URL
page_url URL.url('?<%=params[:extra]%>')
@@ -52,23 +53,6 @@ class PanelPage
font('body')
end
def language_to_code(language)
case language
when 'German'
'de'
when 'English'
'en'
when 'Finnish'
'fi'
when 'Hebrew'
'he'
when 'Hindi'
'hi'
else
pending
end
end
private
def font(selector)
@browser.execute_script( "return $( '#{selector}' ).css( 'font-family' );" )