mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5832 Add color legend data with import from LYR file.
This commit is contained in:
committed by
Kristian Bendiksen
parent
3e5c77e79e
commit
6cb86d4792
85
ApplicationCode/UnitTests/RifColorLegendData-Test.cpp
Normal file
85
ApplicationCode/UnitTests/RifColorLegendData-Test.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
#include "QDir"
|
||||
#include "RiaTestDataDirectory.h"
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithoutColor )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 0 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 3" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
}
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithColorName )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013ColorName.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
cvf::Color3f formationColor;
|
||||
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
||||
EXPECT_TRUE( colorPresent );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
EXPECT_EQ( 1.0f, formationColor.r() );
|
||||
EXPECT_EQ( 0.0f, formationColor.g() );
|
||||
EXPECT_EQ( 0.0f, formationColor.b() );
|
||||
}
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithColorHTML )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013ColorHTML.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
cvf::Color3f formationColor;
|
||||
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
||||
EXPECT_TRUE( colorPresent );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
EXPECT_EQ( 1.0f, formationColor.r() );
|
||||
EXPECT_EQ( 0.0f, formationColor.g() );
|
||||
EXPECT_EQ( 0.0f, formationColor.b() );
|
||||
}
|
||||
Reference in New Issue
Block a user