Merge changes I79768c0e,Ideb86f1d

* changes:
  Use test API to create change with deleted/renamed file
  Stop using deprecated method to create test changes
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolver.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolver.java
index 2f55c21..07d1c7c 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolver.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerResolver.java
@@ -268,7 +268,7 @@
    * Resolves the given {@link CodeOwnerReference}s to {@link CodeOwner}s.
    *
    * <p>The accounts for the given {@link CodeOwnerReference}s are loaded from the account cache in
-   * parallel (via {@link AccountCache#get(Set)}.
+   * parallel (via {@link AccountCache#get(Collection)}.
    *
    * @param codeOwnerReferences the code owner references that should be resolved
    * @param annotationsByCodeOwnerReference annotations by code owner reference
diff --git a/web/code-owners-service.ts b/web/code-owners-service.ts
index 9e38a6b..746f364 100644
--- a/web/code-owners-service.ts
+++ b/web/code-owners-service.ts
@@ -322,13 +322,15 @@
       info: FetchedOwner;
     }>
   ): Array<FetchedFile> {
-    return files.map(file => {
-      return {
-        path: file.path,
-        info: file.info,
-        status: this.computeFileStatus(codeOwnerStatusMap, file.path),
-      };
-    });
+    return files
+      .map(file => {
+        return {
+          path: file.path,
+          info: file.info,
+          status: this.computeFileStatus(codeOwnerStatusMap, file.path),
+        };
+      })
+      .sort((a, b) => CodeOwnerService.specialFilePathCompare(a.path, b.path));
   }
 
   private isOnNewerPatchset(patchsetId: number) {
@@ -392,4 +394,30 @@
     ownerService.reset();
     ownerService = undefined;
   }
+
+  // Copied from https://cs.opensource.google/gerrit/gerrit/gerrit/+/master:polygerrit-ui/app/utils/path-list-util.ts;l=10;drc=57014d5ba3e0b48e3372e3aa3c67463cb6e56bca
+  static specialFilePathCompare(a: string, b: string) {
+    const aLastDotIndex = a.lastIndexOf('.');
+    const aExt = a.substr(aLastDotIndex + 1);
+    const aFile = a.substr(0, aLastDotIndex) || a;
+
+    const bLastDotIndex = b.lastIndexOf('.');
+    const bExt = b.substr(bLastDotIndex + 1);
+    const bFile = b.substr(0, bLastDotIndex) || b;
+
+    // Sort header files above others with the same base name.
+    const headerExts = ['h', 'hh', 'hxx', 'hpp'];
+    if (aFile.length > 0 && aFile === bFile) {
+      if (headerExts.includes(aExt) && headerExts.includes(bExt)) {
+        return a.localeCompare(b);
+      }
+      if (headerExts.includes(aExt)) {
+        return -1;
+      }
+      if (headerExts.includes(bExt)) {
+        return 1;
+      }
+    }
+    return aFile.localeCompare(bFile) || a.localeCompare(b);
+  }
 }