Search Results

Search found 3 results on 1 pages for 'phtrivier'.

Page 1/1 | 1 

  • Using Mock for event listeners in unit-testing

    - by phtrivier
    I keep getting to test this kind of code (language irrelevant) : public class Foo() { public Foo(Dependency1 dep1) { this.dep1 = dep1; } public void setUpListeners() { this.dep1.addSomeEventListener(.... some listener code ...); } } Typically, you want to test what when the dependency fires the event, the class under tests reacts appropriately (in some situation, the only purpose of such classes is to wire lots of other components, that can be independently tested. So far, to test this, I always end up doing something like : creating a 'stub' that implements both a addXXXXListener, that simply stores the callback, and a fireXXXX, that simply calls any registered listener. This is a bit tedious since you have to create the mock with the right interface, but that can do use an introspective framework that can 'spy' on a method, and inject the real dependency in tests Is there a cleaner way to do this kind of things ?

    Read the article

  • Is there a way to access the locale used by gettext under windows ?

    - by phtrivier
    I have a program where i18n is handled by gettext. The program works fine, however for some reason I need to know the name of the locale used by gettext at runtime (something like 'fr_FR') under win32. I looked into gettext sources, and there is a quite frightening function that computes it on all platforms (gl_locale_name, in a C file called "localename.h/c"). However, this file does not seem to be installed alongside gettext or libintl, so I can't seem to call the function. Is there another function provided by gettext to get this value ? Or in another package (boost, glib, anything ?) (On a related note, there is a thing called std::locale in the C++ standard library, and according to the doc calling std::locale("") should create a locale with the settings of the system, unless I am mistaken ... but then the name is 'C' under windows. Is it a viable way of getting the locale name ? What I am doing wrong ?)

    Read the article

  • Adapting the width of a Flexs 3 DataGridColumn to the content of its ItemRenderer ?

    - by phtrivier
    I have the following scenario : A Flex 3 DataGrid is sitting here At runtime, a column is added to this grid The column has a custom ItemRenderer The ItemRenderer inherits from HBox, and adds a few items to the HBOx dynamically My problem is that the width of the column doesn't change. As a consequence, my column stays small, and an ugly horizontal scrollbar is displayed in the line, instead of my content (which is completely unreadable). I would like the column to adapt its width to the content of the HBox in the ItemRenderer. I tried the following : Setting the 'percentWidth' of the ItemRenderer to '100' Invalidating the properties of the ItemRenderer after adding the items The only thing that has a "visible" effect it to force the width of the DataGridColumn. Obviously this is not acceptable since I'm dynamically adding components to the ItemRenderer, and I don't know how many or how big they are. Besides, when I am in the ItemRenderer, I have no access to the column itself (or do I ?) so I cannot force the size of the column from here. So is there a way around this ? Would AdvancedDataGrid help here (notwhistanding the fact that I cannot really use it for other reasons ...) Thanks PH

    Read the article

1