mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 03:08:12 +08:00
67 lines
1.9 KiB
C++
Executable File
67 lines
1.9 KiB
C++
Executable File
#include <gtest/gtest.h>
|
|
#include <cdroid.h>
|
|
#include <ngl_os.h>
|
|
#include <app/alertdialog.h>
|
|
|
|
using namespace cdroid;
|
|
|
|
class DIALOG:public testing::Test{
|
|
|
|
public :
|
|
virtual void SetUp(){
|
|
}
|
|
virtual void TearDown(){
|
|
}
|
|
};
|
|
|
|
TEST_F(DIALOG,1Button){
|
|
App app;
|
|
AlertDialog::Builder(&app)
|
|
.setTitle("DialogTest")
|
|
.setMessage("Hello ,every one! This is an multiline messagebox Example\n this is the second line\nis this OK?")
|
|
.setPositiveButton("OK",[](DialogInterface&,int){App::getInstance().exit(0);})
|
|
.show();
|
|
ASSERT_EQ(0,app.exec());
|
|
}
|
|
|
|
TEST_F(DIALOG,2Button){
|
|
App app;
|
|
AlertDialog::Builder(&app)
|
|
.setTitle("DialogTest")
|
|
.setMessage("Hello ,every one! This is an multiline messagebox Example\n this is the second line\nis this OK?")
|
|
.setPositiveButton("Yes",nullptr)
|
|
.setNegativeButton("No",[](DialogInterface&,int){App::getInstance().exit(1);})
|
|
.show();
|
|
ASSERT_EQ(1,app.exec());
|
|
}
|
|
|
|
TEST_F(DIALOG,3Button){
|
|
App app;
|
|
AlertDialog::Builder(&app)
|
|
.setTitle("DialogTest")
|
|
.setMessage("Hello ,every one! This is an multiline messagebox Example\n this is the second line\nis this OK?")
|
|
.setPositiveButton("Yes",nullptr)
|
|
.setNegativeButton("No",nullptr)
|
|
.setNeutralButton("Cancel",[](DialogInterface&,int){App::getInstance().exit(2);})
|
|
.show();
|
|
ASSERT_EQ(2,app.exec());
|
|
}
|
|
|
|
TEST_F(DIALOG,Choices){
|
|
App app;
|
|
std::vector<std::string>items;
|
|
for(int i=0;i<10;i++){
|
|
std::ostringstream oss;
|
|
oss<<"item-"<<i;
|
|
items.push_back(oss.str());
|
|
}
|
|
AlertDialog::Builder(&app)
|
|
.setTitle("DialogTest")
|
|
.setSingleChoiceItems(items,0,nullptr)
|
|
.setPositiveButton("Yes",nullptr)
|
|
.setNegativeButton("No",[](DialogInterface&,int){App::getInstance().exit(1);})
|
|
.show();
|
|
app.exec();
|
|
}
|
|
|