title: Change locale while executing Espresso test
body: <p>I am creating a simple layout that should support arabic language and RTL layout. Everything works fine. Now I want to write an Espresso test and assert weather it's actually showing the translated text or not. e.g. For arabic language it should display text from arabic strings.xml.</p>
  
  <p>So far I tried below code as a TestRule.</p>
  
  <pre><code>public void setLocale(Locale locale) {
          Resources resources = InstrumentationRegistry.getTargetContext().getResources();
          Locale.setDefault(locale);
          Configuration config = resources.getConfiguration();
          config.locale = locale;
          resources.updateConfiguration(config, resources.getDisplayMetrics());
      }
  </code></pre>
  
  <p>The above code changes the layout direction but doesn't load resources from the localised directory.</p>
  
  <p>I am not doing anything extra but something like <a href="http://www.andreamaglie.com/2016/a-test-rule-for-setting-device-locale/" rel="noreferrer">http://www.andreamaglie.com/2016/a-test-rule-for-setting-device-locale/</a></p>
  
  <p>Am I missing anything? </p>