Package org.intellij.erlang.marker

Source Code of org.intellij.erlang.marker.ErlangMethodSeparatorProviderTest

/*
* Copyright 2012-2014 Sergey Ignatov
*
* 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 org.intellij.erlang.marker;

import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
import org.intellij.erlang.utils.ErlangLightPlatformCodeInsightFixtureTestCase;

import java.util.List;

public class ErlangMethodSeparatorProviderTest extends ErlangLightPlatformCodeInsightFixtureTestCase {
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    setShowMethodSeparatorsEnabled(true);
  }

  @Override
  protected void tearDown() throws Exception {
    super.tearDown();
    setShowMethodSeparatorsEnabled(false);
  }

  @Override
  protected String getTestDataPath() {
    return "testData/marker/methodSeparators/";
  }

  @Override
  protected boolean isWriteActionRequired() {
    return false;
  }

  private static void setShowMethodSeparatorsEnabled(boolean b) {
    DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
    settings.SHOW_METHOD_SEPARATORS = b;
  }

  protected void doTest(Integer ... expectedLineMarkers) {
    myFixture.configureByFile(getTestName(true) + ".erl");
    myFixture.doHighlighting();
    assertSameElements(getMarkedLineNumbers(), expectedLineMarkers);
  }

  private Integer[] getMarkedLineNumbers() {
    List<LineMarkerInfo> lineMarkers = DaemonCodeAnalyzerImpl.getLineMarkers(myFixture.getEditor().getDocument(), myFixture.getProject());
    assertNotNull(lineMarkers);
    Integer[] markedLineNumbers = new Integer[lineMarkers.size()];
    for (int i = 0; i < lineMarkers.size(); i++) {
      markedLineNumbers[i] = myFixture.getEditor().getDocument().getLineNumber(lineMarkers.get(i).startOffset);
    }
    return markedLineNumbers;
  }

  public void testFunction()              throws Exception { doTest(0); }
  public void testTwoFunctions()          throws Exception { doTest(0, 3); }
  public void testSpec()                  throws Exception { doTest(0); }
  public void testComment()               throws Exception { doTest(0); }
  public void testSpecAndComment()        throws Exception { doTest(0); }
  public void testCommentAndSpec()        throws Exception { doTest(0); }
  public void testCommentSpecAndComment() throws Exception { doTest(0); }
  public void testSpecOfOtherFunction()   throws Exception { doTest(1); }
}
TOP

Related Classes of org.intellij.erlang.marker.ErlangMethodSeparatorProviderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.