Snap for 6494137 from 3668db8602cb0a6d241cf730a412668fbeabfccb to studio-4.1-release

Change-Id: I201de93326c001b2baf0c49ad23d920e5b4c265f
diff --git a/firebase-testing/BUILD b/firebase-testing/BUILD
index 4af73c4..1662b65 100644
--- a/firebase-testing/BUILD
+++ b/firebase-testing/BUILD
@@ -44,7 +44,7 @@
         "//tools/adt/idea/adt-branding:intellij.android.adt.branding",
         "//tools/idea/jvm/jvm-analysis-impl:intellij.jvm.analysis.impl",
         "//tools/idea/java/ide-resources:intellij.java.ide.resources",
-        "//prebuilts/tools/common/m2/repository/com/jetbrains/intellij/documentation/tips-intellij-idea-community/201.8:jar",
+        "//prebuilts/tools/common/m2/repository/com/jetbrains/intellij/documentation/tips-intellij-idea-community/201.11:jar",
         "//tools/idea/java/compiler/instrumentation-util-8:intellij.java.compiler.instrumentationUtil.java8",
         "//tools/idea/.idea/libraries:precompiled_jshell-frontend",
         "//tools/idea/plugins/maven/error-prone-compiler:intellij.maven.errorProne.compiler",
diff --git a/firebase-testing/src/com/google/gct/testing/TwoPanelTree.java b/firebase-testing/src/com/google/gct/testing/TwoPanelTree.java
index 5bb7312..0bb93d1 100644
--- a/firebase-testing/src/com/google/gct/testing/TwoPanelTree.java
+++ b/firebase-testing/src/com/google/gct/testing/TwoPanelTree.java
@@ -24,6 +24,7 @@
 import com.google.gct.testing.dimension.DeviceDimension;
 import com.google.gct.testing.dimension.DeviceDimension.Device;
 import com.intellij.openapi.ui.Splitter;
+import com.intellij.openapi.util.SystemInfo;
 import com.intellij.ui.CheckboxTree;
 import com.intellij.ui.CheckboxTreeBase.CheckPolicy;
 import com.intellij.ui.CheckboxTreeBase.NodeState;
@@ -640,13 +641,10 @@
 
       myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
 
-      if (UIUtil.isUnderGTKLookAndFeel()) {
-        final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
+      if (SystemInfo.isXWindow && UIManager.getLookAndFeel().getName().contains("GTK")) {
+        final Color background = selected ? UIUtil.getTreeSelectionBackground(true) : UIUtil.getTreeBackground();
         UIUtil.changeBackGround(this, background);
       }
-      else if (UIUtil.isUnderNimbusLookAndFeel()) {
-        UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
-      }
 
       if (!leaf) {
         // Disable group radio buttons.
diff --git a/firebase-testing/src/com/google/gct/testing/ui/WipePanel.java b/firebase-testing/src/com/google/gct/testing/ui/WipePanel.java
index f73e12a..fe6522a 100644
--- a/firebase-testing/src/com/google/gct/testing/ui/WipePanel.java
+++ b/firebase-testing/src/com/google/gct/testing/ui/WipePanel.java
@@ -16,7 +16,7 @@
 package com.google.gct.testing.ui;
 
 import com.android.annotations.Nullable;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.ImageUtil;
 
 import javax.swing.*;
 import javax.swing.border.MatteBorder;
@@ -106,7 +106,7 @@
 
     state = revealed;
 
-    buffer = UIUtil.createImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
+    buffer = ImageUtil.createImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
     this.print(buffer.getGraphics()); // Draw the current components on the buffer.
     state = revealing;
 
@@ -140,7 +140,7 @@
     start = System.currentTimeMillis();
 
     state = revealed;
-    buffer = UIUtil.createImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
+    buffer = ImageUtil.createImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
     this.print(buffer.getGraphics()); // Draw the current components on the buffer.
     state = hiding;
 
diff --git a/test-recorder/BUILD b/test-recorder/BUILD
index cdb6731..83e67ce 100644
--- a/test-recorder/BUILD
+++ b/test-recorder/BUILD
@@ -36,7 +36,7 @@
         "//tools/adt/idea/adt-branding:intellij.android.adt.branding",
         "//tools/idea/jvm/jvm-analysis-impl:intellij.jvm.analysis.impl",
         "//tools/idea/java/ide-resources:intellij.java.ide.resources",
-        "//prebuilts/tools/common/m2/repository/com/jetbrains/intellij/documentation/tips-intellij-idea-community/201.8:jar",
+        "//prebuilts/tools/common/m2/repository/com/jetbrains/intellij/documentation/tips-intellij-idea-community/201.11:jar",
         "//tools/idea/java/compiler/instrumentation-util-8:intellij.java.compiler.instrumentationUtil.java8",
         "//tools/idea/.idea/libraries:precompiled_jshell-frontend",
         "//tools/idea/plugins/maven/error-prone-compiler:intellij.maven.errorProne.compiler",
diff --git a/test-recorder/src/com/google/gct/testrecorder/codegen/TestCodeMapper.java b/test-recorder/src/com/google/gct/testrecorder/codegen/TestCodeMapper.java
index 08d7c91..3faa293 100644
--- a/test-recorder/src/com/google/gct/testrecorder/codegen/TestCodeMapper.java
+++ b/test-recorder/src/com/google/gct/testrecorder/codegen/TestCodeMapper.java
@@ -15,6 +15,19 @@
  */
 package com.google.gct.testrecorder.codegen;
 
+import static com.google.common.base.Strings.isNullOrEmpty;
+import static com.google.gct.testrecorder.codegen.MatcherBuilder.Kind.ClassName;
+import static com.google.gct.testrecorder.codegen.MatcherBuilder.Kind.ContentDescription;
+import static com.google.gct.testrecorder.codegen.MatcherBuilder.Kind.Id;
+import static com.google.gct.testrecorder.codegen.MatcherBuilder.Kind.Text;
+import static com.google.gct.testrecorder.event.TestRecorderAssertion.EXISTS;
+import static com.google.gct.testrecorder.event.TestRecorderAssertion.NOT_EXISTS;
+import static com.google.gct.testrecorder.event.TestRecorderAssertion.TEXT_IS;
+import static com.google.gct.testrecorder.util.StringHelper.boxString;
+import static com.google.gct.testrecorder.util.StringHelper.getClassName;
+import static com.google.gct.testrecorder.util.StringHelper.lowerCaseFirstCharacter;
+import static com.google.gct.testrecorder.util.StringHelper.parseId;
+
 import com.android.SdkConstants;
 import com.android.annotations.VisibleForTesting;
 import com.android.resources.ResourceType;
@@ -31,20 +44,14 @@
 import com.intellij.lang.java.lexer.JavaLexer;
 import com.intellij.openapi.project.Project;
 import com.intellij.pom.java.LanguageLevel;
-import org.apache.commons.lang.StringUtils;
-import org.jetbrains.android.sdk.AndroidTargetData;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static com.google.gct.testrecorder.codegen.MatcherBuilder.Kind.*;
-import static com.google.gct.testrecorder.event.TestRecorderAssertion.*;
-import static com.google.gct.testrecorder.util.StringHelper.*;
+import org.apache.commons.lang.StringUtils;
+import org.jetbrains.android.sdk.AndroidTargetData;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 public class TestCodeMapper {
 
@@ -327,7 +334,10 @@
     int groupViewChildPosition = elementDescriptor.getGroupViewChildPosition();
 
     // Do not use child position for ViewPager children as it changes dynamically and non-deterministically.
-    if (SdkConstants.CLASS_VIEW_PAGER.isEquals(elementDescriptors.get(index + 1).getClassName())) {
+    if (SdkConstants.CLASS_VIEW_PAGER.isEquals(elementDescriptors.get(index + 1).getClassName())
+        // Do not use child position for assertions due to potential child position mismatches between UIAutomator (when assertion is
+        // recorded) and Espresso (when assertion is replayed/verified).
+        || isAssertionConditions) {
       groupViewChildPosition = -1;
     }
 
diff --git a/test-recorder/src/com/google/gct/testrecorder/ui/RecordingDialog.java b/test-recorder/src/com/google/gct/testrecorder/ui/RecordingDialog.java
index 1655a0f..284bc1b 100644
--- a/test-recorder/src/com/google/gct/testrecorder/ui/RecordingDialog.java
+++ b/test-recorder/src/com/google/gct/testrecorder/ui/RecordingDialog.java
@@ -990,8 +990,7 @@
 
     String className = getClassName(node);
     String resourceId = getResourceId(node);
-    // Use text identification only for text views.
-    String text = isTextView(node) ? getText(node) : "";
+    String text = getText(node);
     String contentDescription = getContentDescription(node);
     int viewGroupChildPosition = getViewGroupChildPosition(node);