Merge "Ignore ?attr/windowActionBar when displaying menus"
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
index 537fa77..97698df 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
@@ -360,8 +360,10 @@
                 return;
             }
             // Check if an actionbar is needed
-            boolean windowActionBar = getBooleanThemeValue(mResources, ATTR_WINDOW_ACTION_BAR,
-                    !mContext.isAppCompatTheme(), true);
+            boolean isMenu = "menu".equals(mParams.getFlag(RenderParamsFlags.FLAG_KEY_ROOT_TAG));
+            boolean windowActionBar = isMenu ||
+                    getBooleanThemeValue(mResources, ATTR_WINDOW_ACTION_BAR,
+                            !mContext.isAppCompatTheme(), true);
             if (windowActionBar) {
                 mActionBarSize = getDimension(ATTR_ACTION_BAR_SIZE, true, DEFAULT_TITLE_BAR_HEIGHT);
             } else {
diff --git a/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png b/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png
new file mode 100644
index 0000000..4e448c8
--- /dev/null
+++ b/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png b/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png
new file mode 100644
index 0000000..290018b
--- /dev/null
+++ b/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/src/main/res/layout/simple_activity.xml b/bridge/tests/res/testApp/MyApplication/src/main/res/layout/simple_activity.xml
new file mode 100644
index 0000000..14b93f3
--- /dev/null
+++ b/bridge/tests/res/testApp/MyApplication/src/main/res/layout/simple_activity.xml
@@ -0,0 +1,32 @@
+<!--
+  ~ Copyright (C) 2016 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:paddingLeft="@dimen/activity_horizontal_margin"
+                android:paddingRight="@dimen/activity_horizontal_margin"
+                android:paddingTop="@dimen/activity_vertical_margin"
+                android:paddingBottom="@dimen/activity_vertical_margin">
+
+    <TextView
+        android:text="@string/hello_world"
+        android:layout_width="wrap_content"
+        android:layout_height="200dp"
+        android:background="#FF0000"
+        android:id="@+id/text1"/>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java b/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java
index d160268..e7c6cc9 100644
--- a/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java
+++ b/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java
@@ -320,6 +320,35 @@
         }
     }
 
+    @Test
+    public void testActivityActionBar() throws ClassNotFoundException {
+        LayoutPullParser parser = createLayoutPullParser("simple_activity.xml");
+        LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
+        layoutLibCallback.initResources();
+
+        SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5,
+                layoutLibCallback, "Theme.Material.Light.NoActionBar", false,
+                RenderingMode.V_SCROLL, 22);
+
+        renderAndVerify(params, "simple_activity_noactionbar.png");
+
+        parser = createLayoutPullParser("simple_activity.xml");
+        params = getSessionParams(parser, ConfigGenerator.NEXUS_5,
+                layoutLibCallback, "Theme.Material.Light", false,
+                RenderingMode.V_SCROLL, 22);
+
+        renderAndVerify(params, "simple_activity.png");
+
+        // This also tests that a theme with "NoActionBar" DOES HAVE an action bar when we are
+        // displaying menus.
+        parser = createLayoutPullParser("simple_activity.xml");
+        params = getSessionParams(parser, ConfigGenerator.NEXUS_5,
+                layoutLibCallback, "Theme.Material.Light.NoActionBar", false,
+                RenderingMode.V_SCROLL, 22);
+        params.setFlag(RenderParamsFlags.FLAG_KEY_ROOT_TAG, "menu");
+        renderAndVerify(params, "simple_activity.png");
+    }
+
     /** Test allwidgets.xml */
     @Test
     public void testAllWidgets() throws ClassNotFoundException {