Bug 1263726 - Settings title remains as "Language" after switching locale and returning to "General Settings". r=grisha
MozReview-Commit-ID: KRNPjPJc2aS
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -277,21 +277,21 @@ OnSharedPreferenceChangeListener
// Because Android just rebuilt the activity itself with the
// old language, we need to update the top title and other
// wording again.
if (onIsMultiPane()) {
updateActionBarTitle(R.string.settings_title);
}
// Update the title to for the preference pane that we're currently showing.
- int titleId = getIntent().getExtras().getInt(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE);
+ final int titleId = getIntent().getExtras().getInt(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE);
if (titleId != NO_SUCH_ID) {
setTitle(titleId);
} else {
- Log.e(LOGTAG, "Title id not found in intent bundle extras");
+ throw new IllegalStateException("Title id not found in intent bundle extras");
}
// Don't finish the activity -- we just reloaded all of the
// individual parts! -- but when it returns, make sure that the
// caller knows the locale changed.
setResult(RESULT_CODE_LOCALE_DID_CHANGE);
return;
}
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/UITest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/UITest.java
@@ -1,33 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.Assert;
-import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.Driver;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.tests.components.AboutHomeComponent;
import org.mozilla.gecko.tests.components.AppMenuComponent;
import org.mozilla.gecko.tests.components.BaseComponent;
import org.mozilla.gecko.tests.components.GeckoViewComponent;
-import org.mozilla.gecko.tests.components.SettingsComponent;
import org.mozilla.gecko.tests.components.TabStripComponent;
import org.mozilla.gecko.tests.components.ToolbarComponent;
import org.mozilla.gecko.tests.helpers.HelperInitializer;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.text.TextUtils;
-
import com.robotium.solo.Solo;
/**
* A base test class for Robocop (UI-centric) tests. This and the related classes attempt to
* provide a framework to improve upon the issues discovered with the previous BaseTest
* implementation by providing simple test authorship and framework extension, consistency,
* and reliability.
*
@@ -40,17 +32,16 @@ abstract class UITest extends BaseRoboco
private static final String JUNIT_FAILURE_MSG = "A JUnit method was called. Make sure " +
"you are using AssertionHelper to make assertions. Try `fAssert*(...);`";
protected AboutHomeComponent mAboutHome;
protected AppMenuComponent mAppMenu;
protected GeckoViewComponent mGeckoView;
protected TabStripComponent mTabStrip;
protected ToolbarComponent mToolbar;
- protected SettingsComponent mSettings;
@Override
protected void setUp() throws Exception {
super.setUp();
// Helpers depend on components so initialize them first.
initComponents();
initHelpers();
@@ -61,17 +52,16 @@ abstract class UITest extends BaseRoboco
}
private void initComponents() {
mAboutHome = new AboutHomeComponent(this);
mAppMenu = new AppMenuComponent(this);
mGeckoView = new GeckoViewComponent(this);
mTabStrip = new TabStripComponent(this);
mToolbar = new ToolbarComponent(this);
- mSettings = new SettingsComponent(this);
}
private void initHelpers() {
HelperInitializer.init(this);
}
@Override
public Solo getSolo() {
@@ -118,19 +108,16 @@ abstract class UITest extends BaseRoboco
return mAppMenu;
case GECKOVIEW:
return mGeckoView;
case TOOLBAR:
return mToolbar;
- case SETTINGS:
- return mSettings;
-
default:
fail("Unknown component type, " + type + ".");
return null; // Should not reach this statement but required by javac.
}
}
/**
* Returns the test type. By default this returns MOCHITEST, but tests can override this
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/SettingsComponent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.mozilla.gecko.tests.components;
-
-import com.robotium.solo.Solo;
-
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.tests.UITestContext;
-
-/**
- * Created by root on 6/2/16.
- */
-public class SettingsComponent extends BaseComponent{
-
-
- public SettingsComponent(UITestContext testContext) {
- super(testContext);
- }
-
- /**
- * Open the preference activity from the HOME screen
- *
- */
- public SettingsComponent openPreference() {
- mSolo.sendKey(Solo.MENU);
- mSolo.clickOnMenuItem(mSolo.getString(R.string.settings));
- return this;
- }
-
- /**
- * Go to a particular preference screen given it's title id
- *
- */
- public SettingsComponent goToPreferenceScreen(int id) {
- String text = mSolo.getString(id);
- mSolo.waitForText(text);
- mSolo.clickOnMenuItem(text);
- return this;
- }
-
- /**
- * Bring up the change locale dialog and choose the specified locale
- *
- */
- public SettingsComponent changeLocale(String text) {
- // Using press menu item because Browser Language is a preference category instead of preference screen
- mSolo.pressMenuItem(0);
- mSolo.clickOnMenuItem(text);
- return this;
- }
-
-}
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testPreference.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.mozilla.gecko.tests;
-
-import android.support.v7.app.ActionBar;
-import android.view.View;
-import android.widget.TextView;
-
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.tests.helpers.GeckoHelper;
-
-import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertEquals;
-
-/**
- * Created by root on 6/2/16.
- */
-public class testPreference extends UITest {
-
- private final String PREF_GENERAL = "General";
- private final String PREF_LANGUAGE = "Language";
-
- private final String LOCALE_EN = "English";
- private final String LOCALE_IT = "Italiano";
-
- // Bug 1263726
- public void testTitleUpdatedWhenLocaleChanged() {
- GeckoHelper.blockForReady();
-
- // Change to some language other than english
- mSettings.openPreference();
- mSettings.goToPreferenceScreen(R.string.pref_category_general);
- mSettings.goToPreferenceScreen(R.string.pref_category_language);
- mSettings.changeLocale(LOCALE_IT);
- mSolo.goBack();
-
- // Change back to english
- mSettings.goToPreferenceScreen(R.string.pref_category_language);
- mSettings.changeLocale(LOCALE_EN);
-
- mSolo.waitForText(PREF_LANGUAGE);
- String title = mSolo.getCurrentActivity().getTitle().toString();
- fAssertEquals("Language should be updated", PREF_LANGUAGE, title);
- mSolo.goBack();
- mSolo.waitForText(PREF_GENERAL);
- title = mSolo.getCurrentActivity().getTitle().toString();
- fAssertEquals("General should be updated", PREF_GENERAL, title);
- }
-
-}