how to use multiple coded ui test map - coded-ui-tests

I need to use multiple coded UI test map to separte the action and to enable working in parallel.
but when I try using multiple coded ui test map, I can not find the control. you can find below the scenario.
[TestMethod]
public void CreateDocumentUiTest()
{
LoginScenario();
var bw = BrowserWindow.FromProcess(_proc);
bw.NavigateToUrl(new Uri("http://localhost:48387/#!/Region/Editor/"));
UiMap1.InitializeRegionName(); //line 7
UiMap.ClickSave();
UiMap.ClickRefresh();
UiMap1.IsRegionNameCorrect();
LogoutScenario();
}
public UIMap UiMap => _map ?? (_map = new UIMap());
private UIMap _map;
public UIMap1 UiMap1 => _map1 ?? (_map1 = new UIMap1());
private UIMap1 _map1;
In line 7 I used another UIMap, but it can not find the control.
is there a problem with my code. because when i record the same step with one Coded UImap it is succeed. Any help?

may be the problem is these lines of code
var bw = BrowserWindow.FromProcess(_proc);
bw.NavigateToUrl(new Uri("http://localhost:48387/#!/Region/Editor/"));
when I record them with the new ui map the scenatio success.

Related

Orchard Core Cascade Delete

I have created a content item "Company" that has List Part of items "Offer".
When I delete Company all of it's Offers children are NOT being removed and leave no way to do it later (possibly manually in DB, but that's not the way I'd like to achieve it). Those items are still accessible in the customer user interface (Razor Page).
All of the above happens manually in the Orchard admin panel. I'm using decoupled cms mode.
Is there a possibility to get Orchard to do cascade delete on those items?
I’ve just prepared some fragment of code. Maybe it would be appropriate in your context. Firstly, you should create ContentPartHandler with ListPart as a generic type and override the RemoveAsync method. Then you can get all list items and remove them (as in the example below).
public class MyListPartHandler : ContentPartHandler<ListPart>
{
private readonly IOrchardHelper _orchardHelper;
private readonly IServiceProvider _serviceProvider;
public MyListPartHandler(IOrchardHelper orchardHelper, IServiceProvider serviceProvider)
{
_orchardHelper = orchardHelper;
_serviceProvider = serviceProvider;
}
public override async Task RemovedAsync(RemoveContentContext context, ListPart instance)
{
var items = await _orchardHelper.QueryListItemsAsync(instance.ContentItem.ContentItemId);
var contentManager = _serviceProvider.GetService<IContentManager>();
var tasks = items.Select(item => contentManager.RemoveAsync(item));
await Task.WhenAll(tasks);
}
}
Finally, you should register your handler in the ConfigureServices method of the Startup class.
services.AddContentPart<ListPart>().AddHandler<MyListPartHandler>();

how to invoke an event on a key press

I am making a gambling game in graphics. There are three polygons on screen reading below 3, above 3 and throw a dice. I will incorporate random function generator in throw a dice area. And define two functions when a user enters the area of the rest of two polygons. But I am facing the problem of how to add functions here and how to invoke those function on keypress. Please suggest.
I think should have mentioned the language you are using to code, In case of java swing i have a good solution.
Depending on where you want to trap the "enter" key, you could use an ActionListener (on such components such as text components or buttons) or attach a key binding to your component.
Here is the link how to use Key binding
public class MyPanel extends JPanel {
public MyPanel() {
InputMap im = getInputMap(WHEN_FOCUSED);
ActionMap am = getActionMap();
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter");
am.put("onEnter", new AbstractAction() {
#Override
public void actionPerformed(ActionEvent e) {
// Enter pressed
}
});
}
}
Actually i didn't understand your question, secondly if you are trying to nesting the events you can use threading i have link --Threading with swing.
you can check your question context here and apply it.
Ok and this is all for java, if you are working with other prog. language then please comment.
Thanks..

Dialog values with MvvmCross, ActionBarSherlock and DialogFragment

I have a bunch of different libraries trying to work together and I'm pretty close but there's just one issue.
I have created a class called SherlockDialogFragment inheriting from SherlockFragment (rather than using the SherlockListFragment - this is because of the issue with the keyboard that's covered here). Here is my code:
public class SherlockDialogFragment : SherlockFragment
{
public RootElement Root
{
get { return View.FindViewById<LinearDialogScrollView>(Android.Resource.Id.List).Root; }
set { View.FindViewById<LinearDialogScrollView>(Android.Resource.Id.List).Root = value; }
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var layout = new LinearLayout(Activity) { Orientation = Orientation.Vertical };
var scroll_view = new LinearDialogScrollView(Activity)
{
Id = Android.Resource.Id.List,
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)
};
layout.AddView(scroll_view);
return layout;
}
}
I then do the regular thing of creating an eventsource class which inherits from this but also uses IMvxEventSourceFragment, then the actual fragment class (which I call MvxSherlockDialogFragment) which inherits the eventsource class, as well as IMvxFragmentView.
That all works fine (and indeed I've created a SherlockDialogActivity the same way and it's fine), however the one issue is when I use this fragment on a screen with tabs (i'm using a class I made similarly to above called MvxSherlockFragmentActivity). When switching to the tab with the dialog, the view appears fine, even with pre-populated data. However the issue is when I switch away from that fragment/tab, and then back to it, the dialog elements all have the same value.
In my particular example, it's a login page with a username and password. When I first go into the fragment, everything is fine. When I go out and back in, the password value is in both the username field and the password field.
I'm sure it's got something to do with the SherlockDialogFragment class - in the SherlockDialogActivity class I also have this bit:
public override void OnContentChanged()
{
base.OnContentChanged();
var list = FindViewById<LinearDialogScrollView>(Android.Resource.Id.List);
if (list == null)
{
throw new RuntimeException("Your content must have a ViewGroup whose id attribute is Android.Resource.Id.List and is of type LinearDialogScrollView");
}
list.AddViews();
}
However this doesn't work in a fragment because there's no OnContentChanged event. Also, another difference is that in the SherlockDialogActivity, the layout is being created ONCE in the OnCreate event - however in the SherlockFragmentActivity I've got it being created each time the fragment is viewed. I know that's probably not the best way, but I tried to do it in OnCreate and save it in a variable and then return that variable in OnCreateView, but android didn't like that...
Ok I feel like an idiot. I was creating/binding on OnViewCreated - however I need to do all my binding in OnStart - I think I was following some (possibly old) sample code from Stuart.
Obviously for a regular activity I'm using OnCreate but this doesn't work on a fragment, because the view is not initialised there - it's initialised at OnCreateView.
So for future reference - do all binding in OnStart!

Exception when trying to show a form created in another (background) thread on .netCF with OAC

In a multi form .NetCF 3.5 application I'm trying create the forms in the background while the user is occupied with the previous form.
We're using Orientation Aware Control in the project
We use a wrapper class (FormController) (please let me know if I'm using the wrong terminology) to keep static references to the different forms in our application. Since we only want to create them once.
At the moment the Forms are created the first time they are used. But since this is a time consuming operation we'd like to do this in the background while the user
Application.Run(new FormController.StartUI());
class FormController{
private static object lockObj = new object();
private static bool secIsLoaded = false;
private static StartForm startForm = new StartForm();
private static SecForm m_SecForm;
static SecForm FormWorkOrderList
{
get
{
CreateSecForm();
return m_SecForm;
}
}
private static void StartUI(){
startForm.Show();
ThreadStart tsSecForm = CreateSecForm;
Thread trSecForm = new Thread(tsSecForm);
trSecForm.Priority = ThreadPriority.BelowNormal;
trSecForm.IsBackground = true;
trSecForm.Start();
return startForm;
}
private static void CreateSecForm()
{
Monitor.Enter(lockObj);
if(!secIsLoaded){
m_SecForm = new SecForm();
secIsLoaded = true;
}
Monitor.Exit(lockObj);
}
private static void GotoSecForm()
{
SecForm.Show();
StartForm.Hide();
}
When I call GotoSecForm() the program throws an excepton on SecForm.Show() with an exection with hResult: 2146233067 and no other valuable information.
The stacktrace of the exception is:
on Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar)
on System.Windows.Forms.Control.SuspendLayout()
on b..ctor(OrientationAwareControl control)
on Clarius.UI.OrientationAwareControl.ApplyResources(CultureInfo cultureInfo, Boolean skipThis)
on Clarius.UI.OrientationAwareControl.ApplyResources()
on Clarius.UI.OrientationAwareControl.OnLoad(EventArgs e)
on Clarius.UI.OrientationAwareControl.c(Object , EventArgs )
on System.Windows.Forms.Form.OnLoad(EventArgs e)
on System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
on System.Windows.Forms.Control.set_Visible(Boolean value)
on System.Windows.Forms.Control.Show()
I'm quite qlueless about what's going wrong here. Can anyone help me out?
Or are there some better ways to load the forms in the background?
Let me know if any more information is needed.
You can't create forms (or safely do any manipulation of controls or forms) in background threads. They need to be created on the same thread that the message pump is running on - its just the way that Windows Forms work.
Creating the form itself shouldn't be in itself an expensive task. My advice would be to perform any expensive computations needed to display the form in a background thread, and then pass the result of those computations back to the main message pump in order to create and display the form itself.
(Half way through writing this I realised that this question is about windows mobile, however I'm 99% sure that the above still applies in this situation)

Form won't display. . . Dooh!

I could use a little help. I got this program to work right then I found out I had to use the MVC design. It seems pretty simple but, my little toy program won't display my forms. HELP!! See the below snipets:
PART OF MIDLET
public MileageMidlet()
{
// First get a blank user form
form = new Form("Bradford Gas Mileage Calculator");
startPage = new StartPageView();
inputScreen = new InputScreen();
calculateMileage = new CalculateMileage();
startCmd = new Command ("Start",Command.SCREEN,5);
clearCmd = new Command ("Clear",Command.SCREEN,1);
enterCmd = new Command ("Enter",Command.SCREEN,1);
exitCmd = new Command("Exit", Command.EXIT, 1);
// Set up event handlers to process user commands
form.setCommandListener(this);
}
public void startApp() {
startPage.createView(form);
form.addCommand(startCmd);
form.addCommand(exitCmd);
// Display initial form
Display.getDisplay(this).setCurrent(form);
}
START PAGE VIEW CLASS
import javax.microedition.lcdui.*;
public class StartPageView
{
StringItem strgItm, strgItm2;
private Command startCmd, exitCmd;
public StartPageView()
{
}
public void createView(Form form)
{
// First get a blank user form
form.deleteAll();
form = new Form("Bradford Gas Mileage Calculator");
strgItm = new StringItem ("","Welcome to the Bradford Mobile Gas Mileage Calculator!");
strgItm2 = new StringItem ("","To obtain you gas mileage please click the start button.");
form.append(strgItm);
form.append(strgItm2);
}
I got nothing! Really literally a blue screen.
}
The issue has nothing to do with MIDP or J2ME. The problem is of the semantics of how arguments are passed to methods.
It;s important to remember that arguments to method are passed by value in Java. The consequence is that when an object that is passed to a method, a copy of that reference is passed. Any changes to the reference of the object in the method does not have any affect outside of it.
Please see this article for more information.
So in your code,
form.deleteAll();
form = new Form("Bradford Gas Mileage Calculator");
Comment the above two lines. Everything should be fine.

Resources