mobile/android/base/tests/testAddonManager.java

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 package org.mozilla.gecko.tests;
     3 import org.json.JSONObject;
     4 import org.mozilla.gecko.Actions;
     6 import android.util.DisplayMetrics;
     8 public class testAddonManager extends PixelTest  {
     9     /* This test will check the behavior of the Addons Manager:
    10     First the test will open the Addons Manager from the Menu and then close it
    11     Then the test will open the Addons Manager by visiting about:addons
    12     The test will tap/click on the addons.mozilla.org icon to open the AMO page in a new tab
    13     With the Addons Manager open the test will verify that when it is opened again from the menu no new tab will be opened*/
    15     public void testAddonManager() {
    16         Actions.EventExpecter tabEventExpecter;
    17         Actions.EventExpecter contentEventExpecter;
    18         String url = "about:addons";
    20         blockForGeckoReady();
    22         // Use the menu to open the Addon Manger
    23         selectMenuItem("Add-ons");
    25         // Set up listeners to catch the page load we're about to do
    26         tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
    27         contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
    29         // Wait for the new tab and page to load
    30         tabEventExpecter.blockForEvent();
    31         contentEventExpecter.blockForEvent();
    33         tabEventExpecter.unregisterListener();
    34         contentEventExpecter.unregisterListener();
    36         // Verify the url
    37         verifyPageTitle("Add-ons");
    39         // Close the Add-on Manager
    40         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
    42         // Load the about:addons page and verify it was loaded
    43         loadAndPaint(url);
    44         verifyPageTitle("Add-ons");
    46         // Change the AMO URL so we do not try to navigate to a live webpage
    47         JSONObject jsonPref = new JSONObject();
    48         try {
    49             jsonPref.put("name", "extensions.getAddons.browseAddons");
    50             jsonPref.put("type", "string");
    51             jsonPref.put("value", getAbsoluteUrl("/robocop/robocop_blank_01.html"));
    52             setPreferenceAndWaitForChange(jsonPref);
    54         } catch (Exception ex) { 
    55             mAsserter.ok(false, "exception in testAddonManager", ex.toString());
    56         }
    58         // Load AMO page by clicking the AMO icon
    59         DisplayMetrics dm = new DisplayMetrics();
    60         getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    62         /* Setup the tap to top value + 25px and right value - 25px.
    63         Since the AMO icon is 50x50px this values should set the tap
    64         in the middle of the icon */
    65         float top = mDriver.getGeckoTop() + 25 * dm.density;;
    66         float right = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() - 25 * dm.density;;
    68         // Setup wait for tab to spawn and load
    69         tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
    70         contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
    72         // Tap on the AMO icon
    73         mSolo.clickOnScreen(right, top);
    75         // Wait for the new tab and page to load
    76         tabEventExpecter.blockForEvent();
    77         contentEventExpecter.blockForEvent();
    79         tabEventExpecter.unregisterListener();
    80         contentEventExpecter.unregisterListener();
    82         // Verify tab count has increased
    83         verifyTabCount(2);
    85         // Verify the page was opened
    86         verifyPageTitle("Browser Blank Page 01");
    88         // Addons Manager is not opened 2 separate times when opened from the menu
    89         selectMenuItem("Add-ons");        
    91         // Verify tab count not increased
    92         verifyTabCount(2);
    93     }
    94 }

mercurial