/*
 * Copyright 2000-2016 JetBrains s.r.o.
 *
 * 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.
 */
package git4idea.log;

import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsLogUserFilterTest;
import com.intellij.vcs.log.VcsUser;
import git4idea.test.GitSingleRepoTest;
import git4idea.test.GitTestUtil;
import org.jetbrains.annotations.NotNull;

import static git4idea.test.GitExecutor.modify;

public class GitUserFilterTest extends GitSingleRepoTest {
  private VcsLogUserFilterTest myVcsLogUserFilterTest;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    myVcsLogUserFilterTest = new VcsLogUserFilterTest(GitTestUtil.findGitLogProvider(myProject), myProject) {
      @NotNull
      protected String commit(@NotNull VcsUser user) {
        String userName = user.getName();
        String userEmail = user.getEmail();
        if (SystemInfoRt.isWindows) {
          if (userName.contains("\"")) {
            userName = StringUtil.escapeChar(userName, '"');
          }
          if (userEmail.contains("\"")) {
            userEmail = StringUtil.escapeChar(userEmail, '"');
          }
        }
        GitTestUtil.setupUsername(myProject, userName, userEmail);
        String commit = modify(GitUserFilterTest.this, "file.txt");
        GitTestUtil.setupDefaultUsername(myProject);
        return commit;
      }
    };
  }

  public void testFullMatching() throws Exception {
    myVcsLogUserFilterTest.testFullMatching();
  }

  public void testSynonyms() throws Exception {
    // commit by user with < or > in username does not contain them somewhy
    myVcsLogUserFilterTest.testSynonyms(ContainerUtil.newHashSet('<', '>'));
  }

  public void testTurkishLocale() throws Exception {
    myVcsLogUserFilterTest.testTurkishLocale();
  }

  public void testWeirdCharacters() throws Exception {
    myVcsLogUserFilterTest.testWeirdCharacters();
  }

  public void testWeirdNames() throws Exception {
    myVcsLogUserFilterTest.testWeirdNames();
  }

  public void testJeka() throws Exception {
    myVcsLogUserFilterTest.testJeka();
  }

  @Override
  protected void tearDown() throws Exception {
    myVcsLogUserFilterTest = null;

    super.tearDown();
  }
}

@@ -621,105 +621,8 @@
 g;%0A%0A
-import com.intellij.openapi.util.SystemInfoRt;%0Aimport com.intellij.openapi.util.text.StringUtil;%0A
 impo
@@ -1381,287 +1381,8 @@
 ();%0A
-        if (SystemInfoRt.isWindows) %7B%0A          if (userName.contains(%22%5C%22%22)) %7B%0A            userName = StringUtil.escapeChar(userName, '%22');%0A          %7D%0A          if (userEmail.contains(%22%5C%22%22)) %7B%0A            userEmail = StringUtil.escapeChar(userEmail, '%22');%0A          %7D%0A        %7D%0A
     

fix user filter test under windows: do not escape double quot symbol